Ticket #392 (new defect)

Opened 9 months ago

Last modified 9 months ago

keep-alive slowdown caused by Nagle's Algorithm

Reported by: dalke Owned by: ianb
Priority: normal Milestone: 1.4.1
Component: paste Version: svn-trunk
Severity: normal Keywords:
Cc:

Description

When I use this test program

from paste import httpserver def echo_app(environ, start_response):

n = 10000 start_response("200 Ok", [("Content-Type", "text/plain"),

("Content-Length", str(n))])

return ["*" * n]

httpserver.serve(echo_app, protocol_version="HTTP/1.1")

I get about 1,300 request per second with

httperf --server localhost --port 8080 --num-conn 100

but only about 11 request per second with

httperf --server localhost --port 8080 --num-calls 100

There should be no reason for keep-alive to have such a bad performance.

I tracked it down to the outgoing/response in the server. The server wrote the text to the socket but the OS in the TCP layer buffered the text for up to 0.2s hoping to combine multiple packets into one. But the client is just waiting, so eventually the timeout kicks in. But 5 timeouts for out of 11 (on average) gives a performance of about 11 responses per second.

I've attached a fix, which does

self.socket.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)

Attachments

httpserver.py.diff Download (1.8 KB) - added by dalke 9 months ago.
patch to httpserver.py

Change History

Add/Change #392 (keep-alive slowdown caused by Nagle's Algorithm)

Author


E-mail address and user name can be saved in the Preferences.


Change Properties
<Author field>
Action
as new
as The resolution will be set. Next status will be 'closed'
to The owner will change from ianb. Next status will be 'new'
The owner will change from ianb to anonymous. Next status will be 'assigned'
 
Note: See TracTickets for help on using tickets.