Drupal and Varnish HTTP accellerator

Published on Fri, 2008-10-17 - 15:03

For many reasons, it's a good idea to have a HTTP accelerator/reverse proxy on your webserver to take some of the burdens of HTTP and cache away from Apache and PHP. Squid is most commonly used for this purpose, but after hearing about fellow Dane Poul-Henning Kamp's creation, Varnish, I decided to try that out before messing with that many-armed monster, Squid.

And I was very pleasantly surprised. It took me all of 20 minutes to get working, and the greater part of that was changing all my VHost files to use a different port number, as Varnish is now taking port 80.

If you're reading this, it was served through Varnish. Drupal appears to have no issues at all with being accessed through Varnish. All my sites work as they ought to.

All I did was:

  1. Grab the latest release .debs for Ubuntu Hardy 64-bit
  2. Install them on my webserver
  3. Uncomment the backend default setting in /etc/varnish/default.vcl
  4. Change the port numbers in /etc/default/varnish
  5. Change the port numbers in /etc/apache/ports.conf
  6. Restart Apache and Varnish
  7. Profit!

I did do some tests before number 6 to make sure that everything was working, but I didn't have to change anything. Varnished worked as it should out of the box, and with very little labour, my webserver is now much better prepared if I should ever get Digg'd.

This is of course part of a defense in depth, so I still have APC cache running as well, and some other tricks up my sleeve, should everything go crazy.

But I'd just like to take the opportunity to say thank you, phk and the rest of the Varnish team, for making my life easier.

Tags
The comments for this post are now closed. If you have corrections, suggestions, or other feedback, you can reach me through the contact page.