It had been a slow build, but an incident a few weeks ago made it finally clear: the Walker website was becoming a victim of its own success. A post on the Teens site contained a picture of the Joker for the then-upcoming Batman movie, and as Halloween approached we found ourselves on the front page of Google image search as people began looking for costume ideas. The exponential traffic was crippling our web server:
The biggest problem was simply that Apache is heavy. It’s resource-intensive, especially when you are running several modules as we were – PHP, proxy, cache, etc. The teens site is especially difficult since it runs as a combination of a blog (PHP on Apache 2) and .wac pages (mod_perl & Axkit). Every hit to the Joker post – even if the page was cached – would tie up a number of Apache processes as it served the style sheets, images, and javascript to support the page. We were reaching our MaxClients setting but unable to raise it without running out of memory for our other more intensive servers (mod_perl and postgres, I’m looking at you…).
As this diagram shows, it’s nothing but Apache servers, and it just wasn’t scaling to meet our current demand.
The approach was two-fold: some quick auditing and re-writing of the worst offending .wac pages’ SQL to speed up the slow pages, and yet another web server in front of everything. It was a no brainer to pick Lighttpd, or “Lighty”. It’s written to do one thing – serve static content – and do it extremely fast. Fortunately it can also proxy requests, so it was a pretty simple matter to reassign some ports and write a few rules to route all requests through Lighty.
The end result is astonishing. Our server hums along happily under even the most intense traffic we can throw at it (the email blast for the British Television Advertising Awards) and doesn’t even start to complain. Moving the bulk of the requests to the extremely fast and resource-light server meant we could devote more resources to quickly processing the slow pages (mod_perl). Between the SQL tuning and the extra resources, the bulk of these pages are now served between 2 and 10(!!!) times faster!
The lesson here, for anyone with an Apache server creaking and groaning under increased traffic, is to stop waiting and install Lighty. If your site is PHP-based, you can run this as a fast CGI module from Lighty and do away with Apache altogether. You can also use Lighty to stream (and “scrub”!) flv and mp4 video files. (I’m using both of these techniques for the new ArtsConnectEd.)
The only caveat: be careful as you look for examples on the web. Remarkably, it seems there are many confused webmasters who expect to see a performance boost by putting Lighty behind their struggling Apache. This will not help at all, and in fact will probably make things worse. Lighty has to be first in the chain to take the load off Apache.
Enjoy the speed! I know our server is enjoying the breathing room!
Get Walker Reader in your inbox. Sign up to receive first word about our original videos, commissioned essays, curatorial perspectives, and artist interviews.