Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #31496

Re: bad httplib latency due to IPv6 use

From Roy Smith <roy@panix.com>
Newsgroups comp.lang.python
Subject Re: bad httplib latency due to IPv6 use
Date 2012-10-17 08:17 -0400
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <roy-6C9343.08174617102012@news.panix.com> (permalink)
References <1s42l9-9al.ln1@satorlaser.homedns.org>

Show all headers | View raw


In article <1s42l9-9al.ln1@satorlaser.homedns.org>,
 Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> wrote:

> Hi!
> 
> I noticed yesterday that a single HTTP request to localhost takes 
> roughly 1s, regardless of the actually served data, which is way too 
> long. After some digging, I found that the problem lies in 
> socket.create_connection(), which first tries the IPv6 ::1 and only then 
> tries the IPv4 127.0.0.1. The first one times out after 1s, causing the 
> long latency.
> 
> What I'm wondering is this:
> 1. The server only serves on IPv4, changing this to IPv6 would probably 
> help. However, I wouldn't consider this a bug, or?

This is most likely a configuration problem on your server.  You don't 
say what kind of system you're using, so I can only guess at the exact 
answer, but here's some suggestions.

Look at your /etc/hosts file.  What entries do you have for localhost?  
For example, on my OSX laptop, I've got:

127.0.0.1   localhost
::1             localhost 
fe80::1%lo0 localhost

which gives three IP addresses (one IPv4, two IPv6) for "localhost".  
This works because the box is properly configured for IPv6 (i.e. all 
services of interest listen on both protocols).  On the other hand, this 
is on a linux box I have:

127.0.0.1   localhost
::1     ip6-localhost ip6-loopback

Now, localhost only gives me the IPv4 address.  If I want to connect to 
localhost with IPv6, I have to explicitly say "ip6-localhost".

My guess is that you have some variation of the first example, and what 
you need is some variation on the second.

In the alternative, you need to fix up your HTTP server to listen on 
both protocols.  For sure, in the long term, that's the right solution, 
because Real Soon Now, we're going to run out of IPv4 addresses and 
everybody is going to switch to IPv6.  Of course, that's been true for 
about the past 15 years, but now it's really, really true.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

bad httplib latency due to IPv6 use Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-10-17 09:55 +0200
  Re: bad httplib latency due to IPv6 use Hans Mulder <hansmu@xs4all.nl> - 2012-10-17 11:37 +0200
    Re: bad httplib latency due to IPv6 use Chris Angelico <rosuav@gmail.com> - 2012-10-17 20:44 +1100
    Re: bad httplib latency due to IPv6 use Laszlo Nagy <gandalf@shopzeus.com> - 2012-10-17 11:58 +0200
  Re: bad httplib latency due to IPv6 use Roy Smith <roy@panix.com> - 2012-10-17 08:17 -0400
  Re: bad httplib latency due to IPv6 use Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-10-17 14:40 +0200
    Re: bad httplib latency due to IPv6 use Chris Angelico <rosuav@gmail.com> - 2012-10-18 00:32 +1100
    Re: bad httplib latency due to IPv6 use Roy Smith <roy@panix.com> - 2012-10-17 20:28 -0400
      Re: bad httplib latency due to IPv6 use Chris Angelico <rosuav@gmail.com> - 2012-10-18 14:42 +1100

csiph-web