Varnish can be found at www.varnish-cache.org
“Varnish Cache is an open source, state of the art web application accelerator. You install it on your web server and it makes your website fly.“ – Quote from www.varnish-cache.org.
It’s as simple as dropping it in place. The basic ruleset will begin caching content.
Backends
The web server is known as a backend server and provides the content Varnish will accelerate (cache). So Varnish will sit in-front of any web servers.
Varnish can use one or more backends i.e. multiple web nodes.
Load Balancing
Several backends can be joined together into clusters of backends for load balancing purposes.
Directors
Several backends can be grouped together, these groups are called directors. This will give you increased performance and resilience.
The director can then load balance based on Round-Robin or Random patterns.
Health checks for each backend need to be defined. The checks can be a URL, poll interval and timeout. If a backend fails the checks, it is marked as unhealthy and no traffic is directed to it.
There are a few tools for viewing Varnish statistics :
varnishtop, varnishsizes, varnishsizes, varnishstat
These tools show the counters hits, misses, which URL’s are most popular etc. These are useful when tuning Varnish.
Some gotchas when using Varnish
Cookies
Varnish will not cache a object coming from the backend with a Set-Cookie header present. Also, if the client sends a Cookie header, Varnish will bypass the cache and go directly to the backend.
This can be overly conservative. A lot of sites use Google Analytics (GA) to analyse their traffic. GA sets a cookie to track you. This cookie is used by the client side java script and is therefore of no interest to the server.
Solution:
Get Varnish to strip out the cookies where there are not needed – e.g. on image files etc. This will result in more files being cached.
Encrypted Traffic
Encrypted traffic (port 443) cannot be cached by Varnish. This results in load being placed on the web nodes. A way to get Varnish to cache this traffic is to place an SSL terminating service in-front of the encrypted traffic. A good tool to use is called Pound (http://www.apsis.ch/pound/). Pound will do the SSL termination, it can then pass the clear traffic to Varnish on port 80 and it can be cached.
Upgrading
There are a few stable version of Varnish about, the latest being 3.0. Some important changes have taken place with the new version, so the Varnish site offers a useful guide to upgrading to the latest version.
https://www.varnish-software.com/blog/upgrading-varnish-cache-21-30
ForLinux offers support for Varnish and Magento and also tuning it to enable maximum content caching and fast page-loads. You can find a whitepaper entitled “Magento and Varnish“ on our site – https://forlinux.co.uk/expertise/knowledge-bank/