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:
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!