FastNetMon

Tuesday, 15 December 2009

Apache mod_python prefork vs mpm, тесты

Задался идеей сравнить, в каком режиме mod_python будет работать быстрее вот такой командой:
ab -c 100 -n 1000 xx.xx.xx.xx/mptest.py | grep 'Requests per second'


Тестовый скрипт (правда тестовости в нем ну ни капли):

from mod_python import apache


def handler(req):
req.content_type = 'text/plain'
req.write("Hello World!" + str(2**100) )
return apache.OK



Prefork:

ab -c 100 -n 1000 88.198.35.235/mptest.py
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> 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 88.198.35.235 (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.2.3
Server Hostname: 88.198.35.235
Server Port: 80

Document Path: /mptest.py
Document Length: 43 bytes

Concurrency Level: 100
Time taken for tests: 9.278980 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 190190 bytes
HTML transferred: 43043 bytes
Requests per second: 107.77 [#/sec] (mean)
Time per request: 927.898 [ms] (mean)
Time per request: 9.279 [ms] (mean, across all concurrent requests)
Transfer rate: 19.94 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 89 352.3 3 3002
Processing: 4 593 774.1 197 3077
Waiting: 2 583 767.7 196 2684
Total: 6 682 823.0 466 3080

Percentage of the requests served within a certain time (ms)
50% 466
66% 603
75% 1074
80% 1148
90% 2540
95% 2599
98% 2687
99% 3071
100% 3080 (longest request)



Worker:


ab -c 100 -n 1000 88.198.35.235/mptest.py
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> 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 88.198.35.235 (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.2.3
Server Hostname: 88.198.35.235
Server Port: 80

Document Path: /mptest.py
Document Length: 43 bytes

Concurrency Level: 100
Time taken for tests: 7.688384 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 190000 bytes
HTML transferred: 43000 bytes
Requests per second: 130.07 [#/sec] (mean)
Time per request: 768.838 [ms] (mean)
Time per request: 7.688 [ms] (mean, across all concurrent requests)
Transfer rate: 24.06 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 1 199 453.4 5 1791
Processing: 3 566 603.3 511 2697
Waiting: 3 559 600.3 507 2696
Total: 6 766 699.5 554 2703

Percentage of the requests served within a certain time (ms)
50% 554
66% 864
75% 1192
80% 1400
90% 1796
95% 2132
98% 2700
99% 2701
100% 2703 (longest request)


Провел по пять измерений (работа была через lo интерфейс) для каждого режима работы:

prefork:107.77 [#/sec] (mean)
2294.89 [#/sec] (mean)
2361.05 [#/sec] (mean)
2398.47 [#/sec] (mean)
2617.80 [#/sec] (mean)
2279.28 [#/sec] (mean)

worker:
2844.17 [#/sec] (mean)
2999.95 [#/sec] (mean)
2548.97 [#/sec] (mean)
2589.53 [#/sec] (mean)
2593.53 [#/sec] (mean)


Итого:

prefork: 2389 r/sec
worker: 2714 r/sec


Хотя визуально, "отзывчивость" системы при worker выше, но результаты примерно одинаковые и разница на большем числе измерений, уверен, будет невелика. Так что можно не холиварить и продолжать использовать любой из mpm. Правда вот очень интересно, как осуществляется взаимодействие Apache в режиме Worker и thread safe модулей.

No comments :

Post a Comment

Note: only a member of this blog may post a comment.