Nginx Slower than Apache??

Posted by ichilton on Server Fault See other posts from Server Fault or by ichilton
Published on 2011-02-06T23:18:56Z Indexed on 2011/02/06 23:28 UTC
Read the original article Hit count: 394

Hi,

I've just setup 2x identical Rackspace Cloud instances and am doing some comparisons and benchmarks to compare Apache and Nginx.

I'm testing with a 3.4k png file and initially 512MB server instances but have now moved to 1024MB server instances.

I'm very surprised to see that whatever I try, Apache seems to consistently outperform Nginx....what am I doing wrong?

Nginx:

Server Software:        nginx/0.8.54
Server Port:            80

Document Length:        3400 bytes

Concurrency Level:      100
Time taken for tests:   2.320 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      3612000 bytes
HTML transferred:       3400000 bytes
Requests per second:    431.01 [#/sec] (mean)
Time per request:       232.014 [ms] (mean)
Time per request:       2.320 [ms] (mean, across all concurrent requests)
Transfer rate:          1520.31 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0   11  15.7      3     120
Processing:     1   35  76.9     20    1674
Waiting:        1   31  73.0     19    1674
Total:          1   46  79.1     21    1693

Percentage of the requests served within a certain time (ms)
  50%     21
  66%     39
  75%     40
  80%     40
  90%     98
  95%    136
  98%    269
  99%    334
 100%   1693 (longest request)

And Apache:

Server Software:        Apache/2.2.16
Server Port:            80

Document Length:        3400 bytes

Concurrency Level:      100
Time taken for tests:   1.346 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      3647000 bytes
HTML transferred:       3400000 bytes
Requests per second:    742.90 [#/sec] (mean)
Time per request:       134.608 [ms] (mean)
Time per request:       1.346 [ms] (mean, across all concurrent requests)
Transfer rate:          2645.85 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    1   3.7      0      27
Processing:     0    3   6.2      1      29
Waiting:        0    2   5.0      1      29
Total:          1    4   7.0      1      29

Percentage of the requests served within a certain time (ms)
  50%      1
  66%      1
  75%      1
  80%      1
  90%     17
  95%     19
  98%     26
  99%     27
 100%     29 (longest request)

I'm currently using worker_processes 4; and worker_connections 1024; but i've tried and benchmarked different values and see the same behaviour on all - I just can't get it to perform as well as Apache and from what i've read previously, i'm shocked about this!

Can anyone give any advice?

Thanks,

Ian

© Server Fault or respective owner

Related posts about apache

Related posts about nginx