A few weeks ago I mentioned that we were now hosting CodeBetter.Com in the Rackspace cloud. Overall I was happy with the setup, but one thing kept bugging me. Apache was using a LOT of RAM, and I had to end up scaling the middle tier to two 500M cloud slices in order to keep the site running smoothly. I got one comment that made me cringe since I knew I was having to throw too much hardware at this problem:
Err.. why do you need this much hardware? Surely a blog with 32k subscribers doesn’t need 4 machines, or even decoupled web and database stacks!
I responded that these cloud slices are cheap (and they are @$15/month) and I DO stand behind the decision of having a tiered deployment should we have to scale, but at the same time he was right. A site as small as ours shouldn’t need that much of a footprint. Don’t get me wrong – it’s nice to know that we can scale out should we need to, but I was determined to downsize our current deployment.
I had heard that it was possible to run WordPress under NGINX (the highly performant web server alternative to Apache) but to do it right, you have to jump through some hoops to get it up and running, like building PHP and configuring it to run within the PHP FastCGI Process Manager. After a couple of days of tweaking, we’re happily up and running on ONE NGINX/PHP-FPM middle tier server with 256M ram (behind one NGINX reverse proxy and in front of our MySql server)! It’s probably still overkill, but I like it
I found a few resources which helped me get NGINX/PHP/Wordpress Multisite working, one WordPress support topic and this excellent series of posts by Pranav Rastogi with step by step instructions. If you’re going to do this I suggest checking these out. Also, should you be interested in the gory details of getting this setup, I’ve modified these steps and created a Fabric configuration script to automate this process, which you can find up at my github account.