NGINX Versus Apache Round 2
This is round 2 of my benchmarking of NGINX and Apache for use in serving Skylines Australia. See round 1 here.
I thought after my first small tests that I’d try something a bit more conclusive. Never does my site get a single request at a time, so that was a useless test. Also, as I was testing from home and have many devices here, any of the results could have been affected by something updating itself.
So, in round 2 I tried to make the servers catch on fire. Hopefully Rackspace are not reading this.
Almost the same servers are involved, 2 x 2GB web servers and 1 x 4GB database server. I added a 512MB testing server to run Apache bench from.
From the start I had SO much trouble with Apache. It was so uninterested in serving multiple requests, so much so that even after I changed max connections, keepalive and child processor settings I had to reduce my requests-at-a-time in Apache bench from 1000 to 500 to 50. Apache needed so much massaging.
NGINX was incredible. Zero config changes (besides upping XCache to 64MB.) and the results speak for themselves;
Apache;
[root@SAU-TESTER ~]# ab -c 50 -n 500 http://184.106.112.92/forums/This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 mce_markergt; apache-2.0Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/Copyright 2006 The Apache Software Foundation, http://www.apache.org/Benchmarking 184.106.112.92 (be patient)Completed 100 requestsCompleted 200 requestsCompleted 300 requestsCompleted 400 requestsFinished 500 requestsServer Software: Apache/2.2.3Server Hostname: 184.106.112.92Server Port: 80Document Path: /forums/Document Length: 173443 bytesConcurrency Level: 50Time taken for tests: 215.897595 secondsComplete requests: 500Failed requests: 4(Connect: 0, Length: 4, Exceptions: 0)Write errors: 0Non-2xx responses: 3Total transferred: 86442895 bytesHTML transferred: 86211790 bytesRequests per second: 2.32 [#/sec] (mean)Time per request: 21589.760 [ms] (mean)Time per request: 431.795 [ms] (mean, across all concurrent requests)Transfer rate: 391.00 [Kbytes/sec] receivedConnection Times (ms)min mean[+/-sd] median maxConnect: 0 6 134.0 0 2996Processing: 678 18480 48230.1 1616 211618Waiting: 601 13411 38606.1 1533 209398Total: 678 18486 48228.2 1617 211618Percentage of the requests served within a certain time (ms)50% 161766% 350075% 707680% 864890% 3757095% 17858798% 19667199% 207034100% 211618 (longest request)
[root@SAU-TESTER ~]# ab -c 50 -n 500 http://184.106.78.142/forums/This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/Copyright 2006 The Apache Software Foundation, http://www.apache.org/Benchmarking 184.106.78.142 (be patient)Completed 100 requestsCompleted 200 requestsCompleted 300 requestsCompleted 400 requestsFinished 500 requestsServer Software: nginx/0.6.39Server Hostname: 184.106.78.142Server Port: 80Document Path: /forums/Document Length: 173520 bytesConcurrency Level: 50Time taken for tests: 66.748262 secondsComplete requests: 500Failed requests: 0Write errors: 0Total transferred: 86986500 bytesHTML transferred: 86760000 bytesRequests per second: 7.49 [#/sec] (mean)Time per request: 6674.826 [ms] (mean)Time per request: 133.497 [ms] (mean, across all concurrent requests)Transfer rate: 1272.65 [Kbytes/sec] receivedConnection Times (ms)min mean[+/-sd] median maxConnect: 0 0 2.0 0 25Processing: 991 6361 975.6 6501 7724Waiting: 834 6302 977.7 6439 7653Total: 991 6362 975.5 6503 7724Percentage of the requests served within a certain time (ms)50% 650366% 661975% 672580% 681690% 707595% 717698% 726799% 7393100% 7724 (longest request)
The transfer rate concerned me, so I did a quick ping from the test server;
Average to Apache server: 0.366ms
Average to NGINX server: 0.280ms
So, the connection was a little better, but it still doesn’t explain the differences in load, failed requests (4 for Apache, 0 for NGINX) or Time per request (maybe? Not so sure about this.)
I’m sold. I’ll setup an NGINX test server now to ensure my site runs perfectly on it and then deploy that on the next server. I’m excited.
