cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Multi interface and DNS load balancing

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 10 Dec 2014 23:37:29 +0100 (CET)

On Wed, 10 Dec 2014, Seppo Heikkilä wrote:

> If you take multi-app.c example:
> http://curl.haxx.se/libcurl/c/multi-app.html and use it to connect to a
> server that is using DNS load balancing (has several IPs for one hostname),
> such as google.com, it seems all connections will be established with the
> same IP address.

Well, yes most likely. libcurl will traverse the list of address in the same
order every time it tries to connect to a host that is kept in the DNS cache,
and that will most likely lead to it connecting to the first address in there.

> DNS load balancing is quite common so this should work quite easily.

It isn't easy. getaddrinfo() returns the addresses in a prio order and we go
through the addresses in that order. How are you suggesting we change this
without overriding the users' /etc/gai.conf, RFC 3484 and whatever more that
need to be taken into account?

Of course, involving c-ares complicates matters slightly more too since then
the resolving job is done with the c-ares API instead and that doesn't sort
the entries like getaddrinfo (one of the many tiny ways c-ares is not a
drop-in compatible name resolver).

I'm open for suggestions and patches on how to improve this.

-- 
  / daniel.haxx.se

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-12-10