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.0
Copyright 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 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Finished 500 requests
Server Software:        Apache/2.2.3
Server Hostname:        184.106.112.92
Server Port:            80
Document Path:          /forums/
Document Length:        173443 bytes
Concurrency Level:      50
Time taken for tests:   215.897595 seconds
Complete requests:      500
Failed requests:        4
(Connect: 0, Length: 4, Exceptions: 0)
Write errors:           0
Non-2xx responses:      3
Total transferred:      86442895 bytes
HTML transferred:       86211790 bytes
Requests 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] received
Connection Times (ms)
min  mean[+/-sd] median   max
Connect:        0    6 134.0      0    2996
Processing:   678 18480 48230.1   1616  211618
Waiting:      601 13411 38606.1   1533  209398
Total:        678 18486 48228.2   1617  211618
Percentage of the requests served within a certain time (ms)
50%   1617
66%   3500
75%   7076
80%   8648
90%  37570
95%  178587
98%  196671
99%  207034
100%  211618 (longest request)
NGINX;
[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.0
Copyright 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 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Finished 500 requests
Server Software:        nginx/0.6.39
Server Hostname:        184.106.78.142
Server Port:            80
Document Path:          /forums/
Document Length:        173520 bytes
Concurrency Level:      50
Time taken for tests:   66.748262 seconds
Complete requests:      500
Failed requests:        0
Write errors:           0
Total transferred:      86986500 bytes
HTML transferred:       86760000 bytes
Requests 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] received
Connection Times (ms)
min  mean[+/-sd] median   max
Connect:        0    0   2.0      0      25
Processing:   991 6361 975.6   6501    7724
Waiting:      834 6302 977.7   6439    7653
Total:        991 6362 975.5   6503    7724
Percentage of the requests served within a certain time (ms)
50%   6503
66%   6619
75%   6725
80%   6816
90%   7075
95%   7176
98%   7267
99%   7393
100%   7724 (longest request)
I should also note that while the load on the Apache box reached 50, the NGINX box briefly nudged the low side of 3 before ducking back into the 2’s. Seriously awesome.
The important numbers;
APACHE;
Requests 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] received
Longest resquest:  211618
NGINX;
Requests 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] received
Longest request: 7724

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.

  • what you bring to it contains useful information
    http://www.friv2gaming.com | http://www.yepi10game.com

  • tonyhost

    I'm happy with what is there
    friv

  • Incorvaia Barbara

    Nothing to say. Kizi
    3

  • It really is a good news for the development of new web applications. This promotes the development of a variety of media to be able to have a new step

  • A controversial topic!!! Do like your way of expressing!!

blog comments powered by Disqus