Sunday, March 27, 2011

Nginx and Apache

So I have started playing around with Nginx a bit, normally I am an Apache user. It seems to be the latest fad in web servers for the ruby on rails community. It’s a constant rotation. Last year it seemed that the web server of choice was lighttpd, I am sure for some it still is. Before mongrel, fastcgi was the way to connect your rails app to your web server, whether it be Apache or lighttpd. The first thing I noticed was the difference in the configuration files. They seem organized more like a script or etc rather than a normallinux configuration file. Overall it was pretty easy to replicate my Apache configuration files. I got gzip and expires rolling too. Anyway I will hopefully be putting some performance tests together, as soon as I do I will post them. Here’s a little test … Apache, Nginx head to head with Apachebench. I used a static file for the tests, robots.txt. From this easy test it seems that Nginx is pretty quick. Hopefully, there will be more to come.

Nginx:

Server Software: nginx/0.5.35
Server Hostname: HOST
Server Port: 80

Document Path: /robots.txt
Document Length: 204 bytes

Concurrency Level: 200
Time taken for tests: 1.503728 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 494984 bytes
HTML transferred: 204408 bytes
Requests per second: 665.01 [#/sec] (mean)
Time per request: 300.746 [ms] (mean)
Time per request: 1.504 [ms] (mean, across all concurrent requests)
Transfer rate: 321.20 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 17 91 43.3 99 174
Processing: 25 165 188.4 123 1140
Waiting: 18 135 141.9 113 1004
Total: 67 257 188.8 231 1175

Percentage of the requests served within a certain time (ms)
50% 231
66% 282
75% 290
80% 298
90% 475
95% 605
98% 1018
99% 1162
100% 1175 (longest request)

Apache:

Server Software: Apache/2.2.3
Server Hostname: HOST
Server Port: 80

Document Path: /robots.txt
Document Length: 204 bytes

Concurrency Level: 200
Time taken for tests: 8.891118 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 504510 bytes
HTML transferred: 205020 bytes
Requests per second: 112.47 [#/sec] (mean)
Time per request: 1778.224 [ms] (mean)
Time per request: 8.891 [ms] (mean, across all concurrent requests)
Transfer rate: 55.34 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 30 231.0 8 2999
Processing: 2 437 1153.2 164 8745
Waiting: 1 422 1115.7 162 8745
Total: 69 468 1175.9 169 8770

Percentage of the requests served within a certain time (ms)
50% 169
66% 182
75% 197
80% 223
90% 271
95% 4658
98% 4675
99% 6005
100% 8770 (longest request)

No comments: