NGINX Versus APACHE Round 1
Before any of you read this, keep in mind that I am not a sys admin. I can do server stuff, but I build websites. I dont consider myself an authority on this subject, nor do I expect you to treat this as gospel.
I am going to be moving Skylines Australia to a faster (and cheaper) server shortly. I’ve been doing a lot of research into possible ways I can make the site run quicker and one of the areas of interest for me has been the possibility of using NGINX with PHP FPM and XCache for a more swift browsing experience. As I knew know very little about NGINX and reading a lot of conflicting information about using it, I thought I’d do some tests.
The test was simple and has been labelled Round 1 as I ran out of time.
I spun up an 8GB memory Centos 5.6 machine on Rackspace for the database, a 2GB memory machine for Apache and a 2GB memory machine for NGINX. 3 machines in total.
Apache and NGINX were installed with PHP but no caching and the database was read from the Database machine. This was to make sure that these web serving boxes could utilise the entire system themselves without having to compete with MySQL.
I then wrote a small script to load the site’s index page from my Macbook (pretty simple stuff);
(I’m aware that I could have reduced my code with functions and whatnot, it is just a quick and dirty script so I’m not too concerned about reusability.)
The results before installing any caching were already interesting and surprising.
APACHE AVERAGE: 4.146
NGINX AVERAGE: 5.672
So, surprisingly (for me, at least) Apache was quicker.
I then installed XCache and Memcached. I did very limited config with them both (which I have now lost, so can’t demonstrate.) and ran the script again.
So, while Apache’s average actually increased by .3 seconds, NGINX’s dropped by around 1 second. But, Apache was still quicker.
Now, this test is far from conclusive and the images from all servers have been saved to Cloud Files so when I get some time I’ll spin the same servers up and I am going to try and configure XCache and Memcached a little better and then run the script over 100 iterations to get a more definitive result. As it stands though, NGINX has given me no reason to consider switching from Apache.
If you have any ideas for more conclusive tests I can perform, I’d love to hear them. Keep in mind that I am testing my specific site so I dont want to be directed to other sites that have performed similar tests.
EDIT: See round 2.