4 ms·
Varnish, the reverse proxy, has been my favorite new-to-me technology of 2010. It sits in front of Apache and caches static content (or anything really) based
by spudlyo 16y ago
Varnish, the reverse proxy, has been my favorite new-to-me technology of 2010. It sits in front of Apache and caches static content (or anything really) based on rules you define in the Varnish Configuration Language (VCL).
Varnish is cool because it is very fast. It was written by Poul-Henning Kamp, who has a lot of experience in FreeBSD kernel development. He makes effective use of virtual memory, is careful to avoid memory operations that result in expensive bus transactions on mutli CPU systems, and knows how many system calls it takes to serve up a cache hit. All of this work has paid off. Varnish can turn a plodding CMS into a site that screams, and your profiling tools (siege, apache ab) will fall over before the site does.
Of course it helps if your CMS supports cache control headers, and isn't utterly laden with cookies, but that's where the VCL language comes in. You can write code to strip bogus cookies (like google analytics) coming from both the client and the server which vastly improves your cache hit ratios.
I like the way Varnish uses a shared memory pool for statistics and logging -- a wealth of information about the system is available to you but it doesn't generate a ton of I/O logging it to a file unless you ask it to. I love how you can use the telnet admin interface to compile new VCL code into a running system and then switch to it, while keeping old named configurations around in case you need to revert back.
Varnish has really helped me make slow sites fast this year, although it hasn't happened without some VCL coding effort and some understanding of how the sites operate.
- drewp 16y agoBut despite all that description, all my deployments have been one-liners with 3-4 cmdline params only. It really adds near-zero deployment cost. Squid can do what varnish does, but it's 2x slower by my measurements, and it has a gigantic config file. (Squid can do things that varnish can't, so you may have to use it anyway.)