[python-uk] urllib latency

Alex Willmer alex at moreati.org.uk
Mon Dec 20 15:15:44 CET 2010

On 20 December 2010 13:54, Matt Hamilton <matth at netsight.co.uk> wrote:

> Anyone know why urllib.urlopen() can be so much slower than using ab to do
> the same thing? I seem to be getting an extra 100ms latency on a simple HTTP
> GET request of a static, small image.

Just some possibles:
 - How many DNS lookups is each doing? Have you timed it by IP address, or
with example.com in the hosts file?
 - I understand ab isn't reusing the HTTP connection - could it be reusing
the TCP connection or avoiding the 3-way handshake? (My understanding of
repeated HTTP requests is sketchy)
 - Are ab and urllib transferring the same number of bytes? Is one or the
other (not) using compression?
 - Is ab somehow causing fewer, larger packets to be used in either the
request or the response?

I'd probably be reaching for a packet capture about now.
Alex Willmer <alex at moreati.org.uk>
http://moreati.org.uk/blog http://twitter.com/moreati
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-uk/attachments/20101220/89963dd6/attachment.html>

More information about the python-uk mailing list