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

Tibor Arpas tibor at infinit.sk
Mon Jul 21 19:58:41 CEST 2008


Thanks Robert,

I tried this but no difference :-(. I made sure I changed the right source code.


On Mon, Jul 21, 2008 at 6:28 PM, Robert Brewer <fumanchu at aminus.org> wrote:
> Tibor Arpas wrote:
>> 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.
>
> One possible answer is that wsgiref doesn't disable the Nagle algorithm
> [1].
> Try changing WSGIServer.server_bind to read:
>
>    def server_bind(self):
>        """Override server_bind to store the server name."""
>        import socket
>        self.socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY,
> 1)
>        HTTPServer.server_bind(self)
>        self.setup_environ()
>
>
>
> Robert Brewer
> fumanchu at aminus.org
>
> [1] http://en.wikipedia.org/wiki/Nagle's_algorithm
>
>


More information about the Web-SIG mailing list