cURL / Mailing Lists / curl-library / Single Mail

curl-library

Multi interface and DNS load balancing

From: Seppo Heikkilä <seppo.heikkila_at_gmail.com>
Date: Wed, 10 Dec 2014 19:01:29 +0100

Hi all,

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.

A slightly modified multi-app.c code is attached that shows this behaviour:
./a.out |sort |uniq -c
      1 ares enabled
      1 C-ares: 1.10.1-20141210
      1 Curl version: 7.39.0
    100 Transfer done to IP: 173.194.40.67

If the program is run for a second time, then (usually) another IP is being
used. Several DNS queries are also sent and received but still all the easy
handles use the same IP. This happens with all of the DNS related settings
mentioned in
http://git.io/libcurl-dns
and even if assigning separate share handles (CURLOPT_SHARE) for each easy
handle.

The only way I could get the DNS load balancing to work was by resolving
all the IPs first and then assigning them manually using CURLOPT_RESOLVE.
This is not that nice so is there perhaps some way to disable DNS caching
between curl handles that I did not notice? DNS load balancing is quite
common so this should work quite easily.

Cheers,
Seppo

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html

Received on 2014-12-10