cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: DNS round-robin timeout

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 17 Jan 2012 16:51:32 +0100 (CET)

On Fri, 13 Jan 2012, Pierre Ynard wrote:

> libcurl tries each IP address sequentially and divides the timeout value
> between all of them. Let's say that I set a connection timeout of 2 seconds,
> which seems plenty reasonable for normally responsive hosts. Let's say that
> I hit a host pointing to 10 IP addresses. 2s / 10 = 200 ms, so despite my
> reasonable 2 seconds timeout, libcurl will try to connect to every IP with a
> timeout of only 200 ms.

Yeah. It has been one of those things nagging in the back of my head for years
and we really should improve it. The question is, of course, what the best
approach really is.

> One possibility would be to truncate the list of IP addresses to try,

It would perhaps make sense if we decide that we always spend at least NNN
milliseconds per host name so that if you put say a 5 seconds timeout on a
host name with 100 IP addresses, we still allow a "sensible" time for each
connect attempt. Possibly that "shortest possible time" would be configurable
and could default to something like 1000 or 2000 milliseconds...

> An interesting idea would be, instead of equally dividing 2 seconds, to for
> example try the first address for 1 second, then if it fails the second one
> for 500 ms, then the third one for 250 ms and then whatever

Really? If the first connect fails after a given time, is there really
anything at all that would indicate that the next address would complete the
connection in half the time the previous one didn't succeed on?

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2012-01-17