Moving from Apache to Nginx – wow!

I have been meaning to switch this site from Apache to Nginx for a while now – actually, to tune this website a bit better as a whole. I’ve been using various tools (Google PageSpeed, http://www.monitor.us, http://www.pingdom.com) to track the results and I thought I would recap how things have gone.

When I first started this project, I had a plain vanilla WordPress with no optimization running a handful of plugins on an old Dell 1U Solaris server using Apache+mod_php. PageSpeed showed my initial score to be 75. An infrequent monitor.us performance monitoring was telling me the average response time was about 650ms as a baseline.

My first step was to resize all the “system” images (NOT the gallery images). This bumped the PageSpeed score up to 77.

I tried installing W3 Total Cache, but the whole install was a mess. It wants to run to /wp-content, requests 777 permissions, etc. I had problems with the page display getting messed up, even after clearing the cache. Even though the pages were messed up, the PageSpeed score went to 81. I’m sure I could have figured how to actually get it up and running the way I wanted, but I wanted to do all this by hand anyway, so I scrapped Total Cache and moved on – back to Page Speed score 77.

Next up – enabling mod_gzip on Apache. PageSpeed score increased to 81 – not bad for a simple modification.

I was going to try and install mod_pagespeed from Google, but I had no luck getting it to compile with gcc under Solaris. I love Solaris, but I swear I need to switch to Linux one of these days. None of the new software compiles under Solaris. My list of stuff I can’t get to compile is long: mongodb, mcrypt, mysql-5.5.x, newrelic – and those are just the relics sitting in my /usr/local/src directory that I haven’t deleted in frustration.

Next I installed some object caching via APC, but the PageSpeed score stayed at 81. Adding sendfile and MMAP via the Apache httpd.conf bumped it up to 83.
It was at this point that I started a trial of Pingdom to track the page response times on a more granular level. However, Pingdom was showing page response times of around 975ms, which surprised me since monitor.us showed a drop from 650ms to around 587ms. I wish now I had a baseline number from Pingdom before starting any of this, but oh well.
Next up was the big change – moving from Apache to Nginx+php-fpm. After getting everything configured and tested, I switched. WOW! PageSpeed reports 94, and Pingdom reports response time dropping from 975ms to 237ms (see graphic). Talk about immediate results!
There’s more tuning I plan on doing (like implementing a CDN via S3), though I think all the big gains have been achieved. I’ll update the blog as I get the results.