Load distribution via DNS

from Wikipedia, the free encyclopedia

Round-robin dns ( English Round robin DNS ) is a simple load balancing for network services , in which multiple IP addresses in the Domain Name System an entry to be assigned. Clients have to choose one of these entries at random.

Load balancing via DNS no longer works with most modern web browsers , cURL and Wget . The resolver getaddrinfo , which is increasingly used due to the introduction of IPv6 , no longer delivers entries randomly , but in a preferred order. The previously used resolver gethostbyname still selected entries at random. A client function which again offers randomness is so far only contained in the program library of cURL , but not yet in the command line program cURL.

Round robin DNS does not inherently offer high availability either , as defective entries are still being delivered by the DNS server. If an IP address fails, the client must perform the failover itself . Even if defective entries are automatically removed from the DNS, DNS responses remain in the DNS cache of the client. In contrast to load balancing, most modern web browsers carry out the failover automatically if a DNS entry fails.

functionality

DNS allows multiple IP addresses to be assigned to a name . In more general terms: There can be several resource records with the same label, the same class and the same type, but each with a different data field. Such an arrangement is referred to as a resource record set .

A simple load balancing can be realized with resource record sets .

Example:
    server.example.com.   1800  IN  A  192.0.2.70
    server.example.com.   1800  IN  A  192.0.2.71
    server.example.com.   1800  IN  A  192.0.2.72

If such a name is queried by a resolver , the DNS server basically returns all known IP addresses, but in a changing order. The first request is then answered, for example, with [192.0.2.70, 192.0.2.71, 192.0.2.72] and the second with [192.0.2.71, 192.0.2.72, 192.0.2.70]. It is then the responsibility of the resolver to determine which IP address it actually uses.

The strategy according to which a DNS server specifies the sequence can be configured for BIND-compatible name servers. Three variants are possible with BIND : cyclic, random and fixed . With the fixed variant , the IP addresses are returned in the order in which they are stored in the name server.

Note: Load balancing is not possible for reverse zones of the IN-ADDR.ARPA domain, although several names can be defined for one IP address. A load distribution would not make sense here either.

weighting

With more modern resource record types such as SRV or NAPTR , a weighting can also be defined, which determines which server IP addresses are most frequently in the first place. The corresponding servers are thus addressed more frequently.

In the case of record types that do not provide weighting parameters, the somewhat unsightly but feasible alternative is to assign the IP addresses several times according to their weighting, e.g. B. ADSL line three times, radio link only once.

There is also the option of only returning a few from a pool of possible servers. For example, the Google name server always returns three IP addresses, some of which change. A location-based return delivery of IP addresses is also useful if several distributed data centers are available. B. used by CDNs .

restrictions

The load sharing through DNS is of course only even in the sense of allocation. DNS does not know anything about the actual load that arises afterwards. It is also not checked whether the target servers can be addressed at all. Upstream scripts can check availability and only enter those servers in the name server that are actually currently available. This allows load distribution and reliability to be combined .

Examples of websites that use load balancing via DNS

Individual evidence

  1. It would then become a list of hosts in "preferred" order.
  2. CURLOPT_DNS_SHUFFLE_ADDRESSES
  3. Shuffling DNS addresses