For those of you who didn’t know, Varnish Cache is a powerful open source HTTP accelerator that can be installed infront of any Webserver. Varnish Cache can improve overall performance of your web server by caching contents. The Varnish cache stores the copy of user request’s and serves the same page when the user revisits the webpage. It makes your website really fast and accelerate your web site performance up-to 300 – 1000x (means 80% or more).
Why use Varnish?
- To reduce server load, especially CPU works.
- To make a website load faster, because cached and stored in RAM.
- To gain more visitors to your website.
Install Varnish Cache on CentOS
Step 1. To install, first you must add the varnish yum repository information corresponding to your CentOS/RHEL version to yum:
For CentOS 5.x use:
#rpm --nosignature -i http://repo.varnish-cache.org/redhat/varnish-3.0/el5/noarch/varnish-release-3.0-1.noarch.rpm
For CentOS 6.x use:
#rpm --nosignature -i http://repo.varnish-cache.org/redhat/varnish-3.0/el6/noarch/varnish-release-3.0-1.el6.noarch.rpm
Step 2. Type the following command to install Varnish.
#yum install varnish
Step 3. To start Varnish for the first time, type the following command.
#service varnish start
To start Varnish at system start-up, type the following command to make it start at system boots.
#chkconfig --level 345 varnish on
Configure Varnish Cache 3.0
Configure Varnish config file (/etc/varnish/default.vcl.)
Commands for Monitoring Varnish Cache
Following are the some useful and helpful Varnish Cache commands for monitoring.
# varnishstat : Show varnish statistics.
# varnishlog : Show varnish logs.
# varnishtop : It reads varnishd shared memory logs and presents a most commonly occurring log entries.
# varnishadm : Clear all varnish cache.