Sunday, January 30, 2011

Nginx vs. Django/Apache for serving static files.

This goes without saying really and is a relatively well known nugget, but this post shows the quick and dirty of nginx blowing the pants of django/apache/mod_wsgi for serving static images from a small EC2 instance. Serving static files with django is strongly advised against, so if you're doing it, change the front end stuff over to nginx or lighttpd and proxy back to django/apache.

command: ab -n 10000 -c 200 http://testdomain.com/static/test.xml

Apache/Django - 303.51 req/sec

Document Length: 3247 bytes
Concurrency Level: 200
Time taken for tests: 32.948 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 34760000 bytes
HTML transferred: 32470000 bytes
Requests per second: 303.51 [#/sec] (mean)
Time per request: 658.953 [ms] (mean)
Time per request: 3.295 [ms] (mean, across all concurrent requests)
Transfer rate: 1030.28 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 5 67.5 0 3001
Processing: 83 644 1668.2 323 16566
Waiting: 83 637 1668.2 320 16566
Total: 84 649 1669.9 326 16571

Percentage of the requests served within a certain time (ms)
50% 326
66% 407
75% 502
80% 580
90% 819
95% 1096
98% 8411
99% 9415
100% 16571 (longest request)


Nginx - 4705.07 req/sec


Document Length: 3247 bytes
Concurrency Level: 200
Time taken for tests: 2.125 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 35271448 bytes
HTML transferred: 32471168 bytes
Requests per second: 4705.07 [#/sec] (mean)
Time per request: 42.507 [ms] (mean)
Time per request: 0.213 [ms] (mean, across all concurrent requests)
Transfer rate: 16206.52 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 4 20 10.4 20 47
Processing: 6 22 11.0 22 60
Waiting: 6 22 11.0 22 59
Total: 12 42 14.1 41 89

Percentage of the requests served within a certain time (ms)
50% 41
66% 48
75% 52
80% 54
90% 60
95% 66
98% 75
99% 75
100% 89 (longest request)

Hardly scientific but it's definitely worth showing how significant the difference is.


MoovAtom

No comments:

Post a Comment