Weird difference between nginx and apache

I have made some test related to the speed of apache and nginx on my new
server to see which would be the best for running. Of course the test
have showed me that nginx is the best, there is no fight and no question
about it, but in my test I have found one thing weird.
I have test botch apache and nginx with an image, a small 1-2k image,
but the ab results I have this:

Apache 2.0.63:
Document Path: /img.png
Document Length: 1463 bytes

Total transferred: 17538570 bytes
HTML transferred: 14695835 bytes

Nginx 0.6.32:
Document Path: /img.png
Document Length: 1463 bytes

Total transferred: 16841796 bytes
HTML transferred: 14771911 bytes

My simple question is why?! Is nginx losing something or apache adding
something, if there is perfectly the same image.

Im not so good at this kind of things, I just wanna know if there is
some problems someplace.

Thanks!

On Friday 21 November 2008, Robert G. wrote:

My simple question is why?! Is nginx losing something or apache adding
something, if there is perfectly the same image.

Im not so good at this kind of things, I just wanna know if there is
some problems someplace.

Thanks!

check out “Complete requests”
nginx served more ones

On Friday 21 November 2008, Roxis wrote:

Document Length: 1463 bytes

My simple question is why?! Is nginx losing something or apache adding
something, if there is perfectly the same image.

Im not so good at this kind of things, I just wanna know if there is
some problems someplace.

Thanks!

check out “Complete requests”
nginx served more ones

and apache is adding more http headers than nginx

Roxis wrote:

On Friday 21 November 2008, Roxis wrote:

Document Length: 1463 bytes

My simple question is why?! Is nginx losing something or apache adding
something, if there is perfectly the same image.

Im not so good at this kind of things, I just wanna know if there is
some problems someplace.

Thanks!

check out “Complete requests”
nginx served more ones

and apache is adding more http headers than nginx

Weird, this means that apache http headers are super huge, because if
nginx handles more requests then it should also mean more Kb, but still
apache has more even if it can do less requests.

Thanks!

Im running apache with mod_fastcgi, not mod_php. Also if matter is
running with worker mpm, but dont think is making any difference.

But I guess eider ways it doesnt matter, my tests have showed me that
nginx is the way to go. :slight_smile:

Assuming this is a static file (not proxied from another server), then
nginx will be sending less headers, assuming the default config.

Out of the box apache announces itself with a large “Server: Apache/
httpd mod_this, mod_that, mod_something else”, it also send and Etag
header by default, which nginx does not. If Keep-Alive is enabled,
then apache sends a redundant “Keep-Alive: something” header where
nginx stays mute.

What concerns me is the HTML transfered in both cases is not the same,
it should be identical unless,
a. there is a bug in ab
b. your tests didn’t return the same number of successful results.
c. nginx or apache chose to use chunked encoding to send such a small
file

Cheers

Dave

Robert G. wrote:

Thanks!
check out “Complete requests”
nginx served more ones
and apache is adding more http headers than nginx

Weird, this means that apache http headers are super huge, because if
nginx handles more requests then it should also mean more Kb, but still
apache has more even if it can do less requests.

Thanks!

If you’re using mod_php on Apache, it may lead to an additional header
X-Powered-By if you haven’t explicitly turned expose_php to “off”.
Another header that appears every time in Apache is ETag (entity tag),
but nginx may not send it when this static image is served.
Configurations vary, so if you want to know the details, check out the
Live HTTP headers extension for Firefox, or just use wget with the
“–save-headers” switch.

On 23/11/2008, at 1:17 PM, Dave C. wrote:

c. nginx or apache chose to use chunked encoding to send such a
small file

Scratch that, AB uses HTTP/1.0 by default which prohibits chunked
encoding.

Could you please run your test again, say

ab -n 1000 -c 20 http://site/url

and post the full results.

Cheers

Dave

[[email protected] ~]# curl -I -L srv1.viperhost.net/
HTTP/1.1 200 OK
Server: Nginx
Date: Sun, 23 Nov 2008 09:57:54 GMT
Content-Type: text/html
Connection: keep-alive
Keep-Alive: timeout=65
X-Powered-By: PHP/5.2.6

[[email protected] ~]# curl -I -L srv1.viperhost.net:8080/
HTTP/1.1 200 OK
Date: Sun, 23 Nov 2008 09:57:59 GMT
Server: Apache/2.0.63 (Linux/64)
X-Powered-By: PHP/5.2.6
Vary: Accept-Encoding
Content-Type: text/html

[[email protected] ~]#

Here it is:

[[email protected] ~]# ab -n 1000 -c 200 -k srv1.viperhost.net:8080/img.png
This is ApacheBench, Version 2.0.41-dev <$Revision: 1.121.2.12 $>
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 srv1.viperhost.net (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Finished 1000 requests

Server Software: Apache/2.0.63
Server Hostname: srv1.viperhost.net
Server Port: 8080

Document Path: /img.png
Document Length: 1463 bytes

Concurrency Level: 200
Time taken for tests: 0.66449 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Keep-Alive requests: 1000
Total transferred: 1757049 bytes
HTML transferred: 1463000 bytes
Requests per second: 15049.13 [#/sec] (mean)
Time per request: 13.290 [ms] (mean)
Time per request: 0.066 [ms] (mean, across all concurrent
requests)
Transfer rate: 25809.27 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 2.1 0 11
Processing: 0 1 2.6 0 16
Waiting: 0 1 2.6 0 16
Total: 0 1 4.2 0 18

Percentage of the requests served within a certain time (ms)
50% 0
66% 1
75% 1
80% 2
90% 3
95% 17
98% 17
99% 18
100% 18 (longest request)
[[email protected] ~]# ab -n 1000 -c 200 -k srv1.viperhost.net/img.png
This is ApacheBench, Version 2.0.41-dev <$Revision: 1.121.2.12 $>
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 srv1.viperhost.net (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Finished 1000 requests

Server Software: Nginx
Server Hostname: srv1.viperhost.net
Server Port: 80

Document Path: /img.png
Document Length: 1463 bytes

Concurrency Level: 200
Time taken for tests: 0.49567 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Keep-Alive requests: 1000
Total transferred: 1697000 bytes
HTML transferred: 1463000 bytes
Requests per second: 20174.71 [#/sec] (mean)
Time per request: 9.913 [ms] (mean)
Time per request: 0.050 [ms] (mean, across all concurrent
requests)
Transfer rate: 33429.50 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 1 3.2 0 10
Processing: 3 6 1.2 7 7
Waiting: 3 6 1.3 7 7
Total: 5 7 2.4 7 15

Percentage of the requests served within a certain time (ms)
50% 7
66% 7
75% 7
80% 10
90% 11
95% 13
98% 15
99% 15
100% 15 (longest request)
[[email protected] ~]#

Robert G. wrote:

HTTP/1.1 200 OK
[[email protected] ~]# ab -n 1000 -c 200 -k srv1.viperhost.net:8080/img.png
Total transferred: 1757049 bytes
HTML transferred: 1463000 bytes
[[email protected] ~]# ab -n 1000 -c 200 -k srv1.viperhost.net/img.png
Total transferred: 1697000 bytes
HTML transferred: 1463000 bytes

As you can see, the HTML transferred matches exactly in both cases, so
you know that there is no problem with the data being returned.
HTML = size of the body alone i.e. the image
Total = header + body

Arvind Jayaprakash wrote:

Robert G. wrote:

HTTP/1.1 200 OK
[[email protected] ~]# ab -n 1000 -c 200 -k srv1.viperhost.net:8080/img.png
Total transferred: 1757049 bytes
HTML transferred: 1463000 bytes
[[email protected] ~]# ab -n 1000 -c 200 -k srv1.viperhost.net/img.png
Total transferred: 1697000 bytes
HTML transferred: 1463000 bytes

As you can see, the HTML transferred matches exactly in both cases, so
you know that there is no problem with the data being returned.
HTML = size of the body alone i.e. the image
Total = header + body

OK thanks, it was kind of obvious, but didnt see it.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs