WordPress Varnish ESI Widget is back. Thank you Varnish.
Long ago I wrote the WordPress ESI Widget to help a client’s site stay online during a barrage of traffic. To solve some of the performance problems on high traffic WordPress sites, you have to use caching, but almost all of the caching addons for WordPress do page level caching rather than fragment caching. After the site’s traffic slowed, I stopped development on the widget due to the infrastructure required to support compression.
To compress an ESI assembled page, one needed to run Nginx in front of Varnish and lost some performance as a result. Nginx would take the initial request, pass it to Varnish, Varnish would talk to the backend — which could be the same Nginx server in a somewhat complex configuration — grab the parts, assemble it, hand it back to Nginx which would then compress it and hand it to the surfer.
With Varnish compressing ESI assembled pages, we don’t need the incredibly complex configuration to run ESI. We’re left with a very simple front end cache in front of our backend servers.
Why is Fragment Caching important?
Fragment caching allows the cache to store pieces of the page that may repeat on several pages and assemble those pieces with the rest of the page. The sidebar on your WordPress site only needs to be generated once as someone surfs through your site. This changes the nature of WordPress caching considerably. Compared to the fastest existing WordPress caching plugin, the Varnish ESI widget doubled its performance – bested only by WP Varnish, a plugin that ran Varnish directly and managed cache expiration.
ESI explained simply is probably the best example I have ever found for explaining how ESI works.
But something else is faster
WP Varnish is currently faster, and, for all practical purposes probably always will be on a very busy site. However, on a site that gets a lot of traffic on one page, the second page time to first byte should be faster on an ESI assembled page because the sidebar which contains some of the most computationally expensive parts of the page, doesn’t need to be generated again. While we give up some of the raw speed, we gain an advantage when someone clicks through to read the second page. The perfect use case here is getting publicity for a particular post on your WordPress site, and those surfers decide to read other articles you’ve written.
Varnish’s Original Announcement
From: Poul-Henning Kamp Date: January 25, 2011 6:04:02 AM EST To: varnish-misc@varnish-cache.org Subject: Please help break Varnish GZIP/ESI support before 3.0 One of the major features of Varnish 3.0 is now feature complete, and I need people to start beating it up and help me find the bugs before we go into the 3.0 release cycle. GZIP support ------------ Varnish will ask the backend for gzip'ed objects by default and for the minority of clients that do not grok that, ungzip during delivery. If the backend can not or will not gzip the objects, varnish can be told in VCL to gzip during fetch from the backend. (It can also gunzip, but I don't know why would you do that ?) In addition to bandwidth, this should save varnish storage (one gzip copy, rather than two copies, one gzip'ed one not). GZIP support is on by default, but can be disabled with a parameter. ESI support ----------- Well, we have ESI support already, the difference is that it also understands GZIP'ing. This required a total rewrite of the ESI parser, much improving the readability of it, I might add. So now you can use ESI with compression, something that has hitherto been a faustian bargain, often requiring an afterburner of some kind to do the compression. There are a lot of weird cornercases in this code, (such as including a gzip'ed object in an uncomressed object) so this code really needs beaten up.
What else is there?
Another very important fact is that Varnish will use gzip to request assets from the backend. While this doesn’t sound incredibly important, it is. Now, you can run a Varnish server at another data center and not worry as much about latency. Before this version, any ESI assembled page needed to be fetched uncompressed, and, large pages add tiny bits of latency which result in a poorer experience while surfing. Most installations run Varnish on the same machine or on a machine network topologically close, but, this opens the doors for a CDN to run ESI enabled edge servers to supercharge your WordPress site hosted anywhere.
When will it be here?
Varnish moves quickly, and while the changes are substantial in terms of code rewrites, their code is very well written. I don’t expect we’ll see many bugs in the code and it’ll be released in the next few months. This site and a number of other sites we work with will be running it later this week.
In short, caching for WordPress just got an incredible boost. Even before the compression and gzip request from the backend, the ESI Widget was twice as fast as the fastest non-Varnish enabled plugin and over 440 times faster than WordPress out of the box.
Original Info
* WordPress Cache Plugin Benchmarks
* WordPress, Varnish and Edge Side Includes
* ESI Widget Issues in the Varnish, ESI, WordPress experiment
* A WordPress Widget that Enables one to use Varnish and ESI
January 26th, 2011 at 10:51 am
http://www.varnish-cache.org is running Varnish with compression enabled. :-)
Release is still a couple of weeks away, though.
January 26th, 2011 at 12:06 pm
I estimated a few months in the post, a few weeks is even better. :)