[Web-SIG] Fwd: wsgiref.simple_server slow on slow network

Tibor Arpas tibor at infinit.sk
Tue Jul 22 09:58:06 CEST 2008


I added the Content-Length and no difference. Important thing I
noticed is that I get the same request/response rate with only ONE
byte of content. So it looks like a constant delay of 3 seconds per
request..

Now my script reads:

from wsgiref import simple_server

def app(environ, start_response):
    send = '*'*1
    start_response('200 OK', [('content-type',
'text/html'),('Content-Length',str(len(send)))])
    return send

port = 8080
httpd = simple_server.WSGIServer(('',port),
simple_server.WSGIRequestHandler,)
httpd.set_app(app)
try:
    httpd.serve_forever()
except KeyboardInterrupt:
    pass

#import paste.httpserver
#paste.httpserver.serve(app, host='10.0.0.230', port='8079')  #this works fast!



On Tue, Jul 22, 2008 at 1:51 AM, Graham Dumpleton
<graham.dumpleton at gmail.com> wrote:
> And what happens if you actually supply a content length in your response?
>
> 2008/7/22 Tibor Arpas <tibor at infinit.sk>:
>> Hi,
>> I'm quite new to python and I ran into a performance problem with
>> wsgiref.simple_server. I'm running this little program.
>>
>> from wsgiref import simple_server
>>
>> def app(environ, start_response):
>>   start_response('200 OK', [('content-type', 'text/html')])
>>   return ['*'*50000]
>>
>> httpd = simple_server.make_server('',8080,app)
>> try:
>>   httpd.serve_forever()
>> except KeyboardInterrupt:
>>   pass
>>
>>
>> I get many hundreds of responses/second on my local computer, which is fine.
>> But when I access this server through our VPN it performs very bad.
>>
>> I get 0.33 requests/second as compared to 7 responses/second when
>> accessing 50kB static file served by IIS.
>>
>> I also tried the same little program using paste.httpserver and that
>> version works fast as expected.
>>
>> I cannot really understand this behavior. My only thought is that the
>> wsgiref version is sending the data in many chunks, and therefore the
>> latency of the VPN comes into play. But I don't really know how to
>> test this.
>>
>> This is Python 2.5.2 on Windows Server 2003 (same behavior on Windows
>> XP), testing with Apache AB as well as Firefox...
>>
>> Any help would be appriciated.
>>
>> Tibor
>> _______________________________________________
>> Web-SIG mailing list
>> Web-SIG at python.org
>> Web SIG: http://www.python.org/sigs/web-sig
>> Unsubscribe: http://mail.python.org/mailman/options/web-sig/graham.dumpleton%40gmail.com
>>
>


More information about the Web-SIG mailing list