Noted in brief – 3/1/2011

Migrating WordPress from Apache to Cherokee

[Sorry, this is gonna be a geeky one.  You’ve been warned.]

For the past couple of years, I’ve had this blog on a 256MB VPS slice at Rackspace Cloud, which, overall, has been a very nice ~$12/month experience.  But I’ve chafed a bit at having to restart my Apache web server instance every so often, because it has run out of RAM.  I’m just running a personal blog, goshdarnit.  How can that burn up 256MB of RAM!?!? Turns out the culprit is Apache.  Or, more accurately, the combination of Apache + PHP.  PHP prevents Apache from running in its more memory-efficient “worker” configuration, and the result is that even a site with almost no traffic can easily run out of memory.  Worse, tuning Apache to keep memory usage low means that it starts to perform really poorly.  Bottom line: it’s actually really hard to run a simple WordPress (or other PHP apps) behind Apache on a virtual private server with limited memory.

I’d been casting about for a solution, and had almost settled on using Ngnix, the increasingly popular open-source web server that lots of my friends in the Plone community really love.  But, truth be told, I was a bit intimidated by configuring it to work with PHP, even though it’s far simpler than Apache (which I also barely understand).

Then, David Bain turned me on to Cherokee.  Cherokee is a new-ish open-source web server that is designed to combine the speed of Ngnix with insane ease of configuration + deployment via a user-friendly point-and-click web administration panel.  And, sure enough, it didn’t disappoint.  In about an hour, I was able to install Cherokee, configure PHP, point Cherokee at my WordPress instance, and migrate a few rewrite rules to handle my WordPress shortlinks.

My site is now cranking out over 100 pages/second while RAM usage is well under the maximum and we’re never swapping into virtual memory. Suddenly, the WordPress editing interface feels reasonably responsive.  Vroom!

Looking into the future, I’m pretty excited about the potential to easily deploy Plone behind Cherokee.  Cherokee has built-in, easy-to-configure uWSGI support, which means that we’ll be able to start messing with Plone 4.1 + Cherokee.  (Plone 4.1 will ship with Zope 2.13, which is the first Zope 2 release to ship with unofficial WSGI support.)  This will remain “experimental” for a release or two, until the community’s had time to explore & document best practices.