Network performance

Richie Hindle richie at entrian.com
Tue Aug 23 06:12:20 EDT 2005


[Roland]
> The client sends a number of lines (each ending with \n) and ends one  
> set of lines with a empty line.
> [...]
> I was surprised to find that the performance was [poor].

Are you sending all the lines in a single packet:

>>> sock.send('\n'.join(lines))

or sending them one at a time:

>>> for line in lines:
>>>   sock.send(line + '\n')

?  If the latter, you are probably experiencing "Nagle delays".  Google
will furnish you with any number of explanations of what that means, but
in summary, one end of a TCP/IP connection should never send two
consecutive small packets without receiving a packet from the other end.
('Small' typically means less than about 1400 bytes.)  Each time you do
that, you'll suffer an artificial delay introduced by TCP/IP itself.

-- 
Richie Hindle 
richie at entrian.com



More information about the Python-list mailing list