Archive for the 'benchmark' Category

Apache vs Lighttpd serving Django

Le pôle recherche et développement à récemment ouvert ses portes au linibouplex, il s'agit donc de publier quelques résultats intéressants (c'est plus hype en anglais).

We've decided to show the speed difference between Apache and Lighttpd while serving Django pages.

The test page is classic, a simple view which make a database request (mysql), we're using apachebench for the test. Each test was made several times to ensure the results are corrects. We've made a total of 10000 requests with 100 concurrency requests.

here is the configuration used for Apache:

APACHE MPM-WORKER + MOD PYTHON:

<IfModule mpm_worker_module>
StartServers          5
MaxClients          150
MinSpareThreads      25
MaxSpareThreads      75
ThreadsPerChild      25
MaxRequestsPerChild   0
</IfModule>

and the results:

ab -n 10000 -c 100 http://xxxx.com/test/
[...]
Server Software:        Apache/2.2.9
Server Hostname:        xxxx.com
Server Port:            80
Document Path:          /test/
Document Length:        3304 bytes
Concurrency Level:      100
Time taken for tests:   84.240957 seconds
Complete requests:      10000
Failed requests:        0
Write errors:           0
Total transferred:      35100000 bytes
HTML transferred:       33040000 bytes
Requests per second:    118.71 [#/sec] (mean)
Time per request:       842.410 [ms] (mean)
Time per request:       8.424 [ms] (mean, across all concurrent requests)
Transfer rate:          406.89 [Kbytes/sec] received
Connection Times (ms)
min  mean[+/-sd] median   max
Connect:        0    9 166.8      0    3000
Processing:    14  828 1289.1    744   18824
Waiting:       13  828 1289.1    744   18824
Total:         16  838 1298.6    748   18824
Percentage of the requests served within a certain time (ms)
50%    748
66%    856
75%    863
80%    869
90%    884
95%    914
98%   1447
99%   3569
100%  18824 (longest request)


LIGHTTPD + FCGI:

fastcgi server launched like this:

python manage.py runfcgi method=threaded socket=/home/xxxx/main.sock \
minspare=25 maxspare=75 maxrequest=0 maxchildren 150

and the results:

ab -n 10000 -c 100 http://xxxx.com:8080/test/
[...]
Server Software:        lighttpd/1.4.19
Server Hostname:        xxxx.com
Server Port:            8080
Document Path:          /test/
Document Length:        3304 bytes
Concurrency Level:      100
Time taken for tests:   38.160874 seconds
Complete requests:      10000
Failed requests:        5166
(Connect: 0, Length: 5166, Exceptions: 0)
Write errors:           0
Non-2xx responses:      5166
Total transferred:      19584444 bytes
HTML transferred:       17881094 bytes
Requests per second:    262.05 [#/sec] (mean)
Time per request:       381.609 [ms] (mean)
Time per request:       3.816 [ms] (mean, across all concurrent requests)
Transfer rate:          501.17 [Kbytes/sec] received
Connection Times (ms)
min  mean[+/-sd] median   max
Connect:        0    0   1.3      0       5
Processing:     0  380 299.6    482    2050
Waiting:        0  378 298.9    482    2049
Total:          0  381 300.1    483    2052
Percentage of the requests served within a certain time (ms)
50%    483
66%    589
75%    595
80%    598
90%    618
95%    778
98%   1138
99%   1173
100%   2052 (longest request)


note: Don't worry about the "Failed requests:        5166"  which isn't a real problem as explained here.

Conclusion:

If you don't need specific Apache features it's preferable to use lighttpd which is clearly faster to serve django pages.