Varnish Installation/Configuration

Drupal 6 Varnish Installation (Pressflow)

Walkthrough

1) Install Pressflow

This should be relatively seamless; don't be afraid just to replace your entire Drupal core with Pressflow and simply drop your sites/ directory in. The extra prudent might run Hacked just to make sure core hasn't been altered, but I say move fast and break things.

 

2) Install Varnish

There are relatively comprehensive instructions for installing the basic Varnish service on all the relevant Linux flavors here.

 

3) Configure Varnish

The Four Kitchens wiki has a good starter config setup; you'll probably be placing this in /etc/varnish/default.vcl

 

4) Connect Varnish with Drupal

Install the Varnish module and insert your Varnish Control Key (should be in /etc/varnish/secret) in the module config page (admin/settings/varnish/general).

Additional Resources

https://groups.drupal.org/node/25425

 

Varnish Configuration Tips

Nate Haug has a good article explaining what the config variables mean and giving some good starter tips: https://www.lullabot.com/blog/article/configuring-varnish-high-availability-multiple-web-servers

Using "Grace"

To enable Grace, you just need to specify the setting invcl_recv and in vcl_fetch:

 

# Respond to incoming requests.
sub vcl_recv {
  # Allow the backend to serve up stale content if it is responding slowly.
  set req.grace = 6h;
}

# Code determining what to do when serving items from the Apache servers.
sub vcl_fetch {
  # Allow items to be stale if needed.
  set beresp.grace = 6h;
}

Both of these settings can be the same, but the setting in vcl_fetch must be longer than the setting in vcl_recv. Think of the vcl_fetch grace setting as "the maximum time Varnish should keep an object". The setting in vcl_recv on the other hand defines when Varnish should use a stale object if it has one.