flup perfomance
Хочу разобраться с производительностью питовского flup в режиме FastCGI. Дано:
1) lighttpd с поддержкой mod_fastcgi. Соответствующее место в конфиге выглядит так:
fastcgi.server = ( ".fcgi" =>
( "localhost" =>
(
"socket" => "/tmp/fastcgi.sock",
"bin-path" => "/tmp/test.fcgi",
"check-local" => "disable",
)
)
)
2) питоновский скрипт скопипасченый из flup'овского мануала:
#!/usr/bin/env python
def myapp(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
return ['Hello cruel World!\n']
if __name__ == '__main__':
from flup.server.fcgi_fork import WSGIServer
WSGIServer(myapp, minSpare=1, maxSpare=4).run()
syntax highlighted by Code2HTML, v. 0.9.1
3) перловый скрипт:
#!/usr/bin/env perl
use CGI::Fast qw(:standard);
$COUNTER = 0;
while (new CGI::Fast) {
print header;
print start_html("Fast CGI Rocks");
print
h1("Fast CGI Rocks"),
"Invocation number ",b($COUNTER++),
" PID ",b($$),".",
hr;
print end_html;
}
syntax highlighted by Code2HTML, v. 0.9.1
4) httperf, запускаемый как
$ httperf --server 172.16.1.5 --port 8080 --uri "test.fcgi" --num-conn 5000 --ra 400
Результаты:
1) Перловый вариант отрабатывает все запросы:
Request rate: 369.0 req/s (2.7 ms/req)
...
Reply status: 1xx=0 2xx=5000 3xx=0 4xx=0 5xx=0
2) Питоновский скрипт отрабатывает значительно хуже:
Reply status: 1xx=0 2xx=2727 3xx=0 4xx=0 5xx=0
в top'е часто видно, что test.fcgi в случае питона находится в состоянии defunct
