Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
    
I don't have an answer for the differences in your benchmarks, but I would add that one of the reasons I like using Nginx over Apache is not speed but memory overhead - Nginx tends to use less for us. But those are some unexpected numbers; I wonder if there's something about your Nginx configuration that is not dealing well with a PNG. –  pjmorse Feb 6 '11 at 23:28
    
I'd think the problem is probably configuration side, where Apache does some caching that Nginx wouldn't do. Comparing the two programs, Apache may have a default behavior that needs to be stated in Nginx. –  ring0 Feb 6 '11 at 23:57
    
Are these with default settings? And from what package? i.e. which repo? pre-built package? if not, what build options? –  Beaming Mel-Bin Feb 7 '11 at 0:01
    
Thanks - i'm running Ubuntu 10.10 with Nginx from ppa.launchpad.net/nginx/stable/ubuntu (to get the latest stable version) and default settings. –  ichilton Feb 7 '11 at 0:10
    
Did you check the logs? Isn't nginx hitting some limit you need to tune? You main gain some performance by tuning worker_processes up. –  coredump Feb 7 '11 at 2:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.