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 used ab (ab -c50 -t5s) to benchmark Apache V Nginx for a static file on the same server.

Apache becomes CPU bound at 200 requests per second and Nginx is at about 25% CPU while handline 5211 requests per second.

No swapping took place with Apache, lack of memory wasn't an issue.

I know there are a myriad of different configurations for both Nginx and Apache, but how far behind Apache is Nginx is just ridiculous.

So ridiculous in fact that I think I've missed something with Apache.

Any ideas where to start?

Here are the ab results:

Server Software:        nginx  
Server Port:            80  

Document Path:          /images/15.jpg  
Document Length:        15088 bytes  

Concurrency Level:      50  
Time taken for tests:   5.494 seconds  
Complete requests:      26059  
Failed requests:        0  
Write errors:           0  
Total transferred:      400370476 bytes  
HTML transferred:       393178192 bytes  
Requests per second:    5211.29 [#/sec] (mean)  
Time per request:       9.595 [ms] (mean)  
Time per request:       0.192 [ms] (mean, across all concurrent requests)  
Transfer rate:          78189.48 [Kbytes/sec] received  

Connection Times (ms)  
              min  mean[+/-sd] median   max  
Connect:        0    4   0.6      4      10  
Processing:     3    5   0.8      5      13  
Waiting:        0    2   1.3      2      10  
Total:          6    9   0.9      9      19  

Percentage of the requests served within a certain time (ms)  
  50%      9  
  66%      9  
  75%      9  
  80%      9  
  90%     10  
  95%     10  
  98%     11  
  99%     12  
 100%     19 (longest request)  


Server Software:        Apache  
Server Port:            81  

Document Path:          /images/15.jpg  
Document Length:        15088 bytes  

Concurrency Level:      50  
Time taken for tests:   5.31551 seconds  
Complete requests:      1008  
Failed requests:        0  
Write errors:           0  
Total transferred:      15681815 bytes  
HTML transferred:       15433585 bytes  
Requests per second:    200.34 [#/sec] (mean)  
Time per request:       249.581 [ms] (mean)  
Time per request:       4.992 [ms] (mean, across all concurrent requests)  
Transfer rate:          3043.59 [Kbytes/sec] received  

Connection Times (ms)  
              min  mean[+/-sd] median   max  
Connect:        2   84  47.5     78     222  
Processing:    24  158  46.5    162     260  
Waiting:        1   96  45.1     91     221  
Total:        187  242  48.5    232     428  

Percentage of the requests served within a certain time (ms)  
  50%    232  
  66%    238  
  75%    246  
  80%    249  
  90%    304  
  95%    380  
  98%    409  
  99%    423  
 100%    428 (longest request)  
share|improve this question
    
Please share your config files for nginx and apache. –  Sameer Dec 17 '10 at 17:55
1  
The thing is, nginx is that more powerful... So you may not have missed anything. nginx is highly optimized in a C well-written program. –  ring0 Dec 17 '10 at 18:18
    
The Apache config file is too large to post here. But I can say this, Nginx is the default install from the Atomic Rocket Turtle yum repository and Apache is the default install for Centos 5.5, 64 bit. I may not have missed anything, just thought I'd double check it wasn't something obvious. –  Travis Mijat Dec 17 '10 at 19:00

1 Answer 1

This post is now defunct.

I discovered that this is NOT a standard Apache setup and the extended mod_security rules is the issue.

share|improve this answer
1  
Would you mind performing again the benchmarking without the mod_security module? –  ring0 Dec 18 '10 at 12:32
1  
There isn't enough room here for me to post the full results but I'm getting around 2000 requested per second without mod_security. Yes, literally 10 times the performance. I have subscribed to extensive mod_security rulesets and I have contacted the vendor about the performance. But it's clear, mod_security is limiting Apache's performance and making it CPU bound. –  Travis Mijat Dec 19 '10 at 16:50
    
A 10x reduction in requests per second is not outlandish for mod_security with a big ruleset, this kind of deep HTTP inspection will cost you dearly on performance. You should not use mod_security on basic static file serving, this can be adequately secured by less intrusive means. Only run mod_security in front of a true web application. –  Jesper Mortensen Apr 15 '11 at 9:52

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.