WebFaction
Community site: login faq
1
2

I'd like to use plone.recipe.varnish and plone.app.caching to cache my Plone site - how can I do that?

asked 20 Feb '11, 17:15

seanf
12.2k31836
accept rate: 37%

closed 20 Feb '11, 17:15


A long time ago, I wrote a Plone+Varnish caching HOWTO in the old WebFaction forum. Sometime after I wrote that, Varnish stopped working on our servers, so I rewrote the HOWTO to use Squid. That still works pretty well, but Varnish is quite popular in the Plone community, so I've been wanting to get that working again. I took some time out today to test the latest Varnish with Plone 4, and I'm happy to say that it's working!

Here's the steps I took:

  1. Install a 'custom app listening on port' app in the control panel. You can name the app whatever you want, let's call it "varnish" for example. Make a note of the port number assigned to the app.

  2. Install a Plone 4.1.2 app in the control panel. Let's name the app "zope", and again make a note of the port number.

  3. Edit ~/webapps/zope/zinstance/buildout.cfg to make the following changes:

    • In the eggs section, add plone.recipe.varnish

    • In the parts section, add varnish-build and varnish

    • At the end of buildout.cfg, add the following (change VVVVV to your varnish port, and change ZZZZZ to your Zope port):

    [varnish-build]
    recipe = zc.recipe.cmmi
    url = ${varnish:download-url}

    [varnish] recipe = plone.recipe.varnish daemon = ${buildout:parts-directory}/varnish-build/sbin/varnishd bind = 127.0.0.1:VVVVV backends = 127.0.0.1:ZZZZZ cache-size = 256M

  4. Run your buildout script. You'll need to set a TEMP environment variable to point to a temp directory in your buildout, so do it like this:

    cd ~/webapps/zope/zinstance
    mkdir tmp
    export TEMP=$PWD/tmp
    ./bin/buildout

  5. Start varnish and restart Zope:

    ./bin/varnish
    ./bin/instance restart

  6. Log into your Plone site as an admin, go to Site Setup > Add-ons and install the 'HTTP caching support' add-on.

  7. Go to Site Setup > Caching and make the following settings:

    • Global: enable caching and enable GZip compression checked
    • Caching proxies: enable purging checked, http://127.0.0.1:VVVVV as your proxy (change VVVVV to your Varnish port)
    • Caching operations > Ruleset mappings: Set as desired. The various options (strong, moderate, etc) are explained in the plone.app.caching docs
  8. Edit your site to serve the Varnish app instead of the Zope app. It's a good idea to set up a second site to serve the Zope app directly so that you can still get to your site if there's a problem with Varnish.

Once that's done, just wait a bit for the control panel changes to gel, and then enjoy your new blazingly-fast site. How fast, you say? Well, here's a simple ab benchmark made directly against Zope:

$ ab -n 100 -c 5 http://zope.testweb183.webfactional.com/Plone/ | grep "Requests per second"
Requests per second:    16.47 [#/sec] (mean)

And here's the same site, served through Varnish:

$ ab -n 100 -c 5 http://testweb183.webfactional.com/Plone/ | grep "Requests per second"
Requests per second:    5099.70 [#/sec] (mean)

That's over 300x faster! So, what are you waiting for? :)

permanent link
This answer is marked "community wiki".

answered 20 Feb '11, 17:15

seanf
12.2k31836
accept rate: 37%

edited 19 Feb '12, 14:15

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×28
×23
×7

question asked: 20 Feb '11, 17:15

question was seen: 7,588 times

last updated: 19 Feb '12, 14:15

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM