How Does Load Balancing Work?

This section describes the distribution of traffic for a load balanced group and how it is affected by a planned or unplanned server outage.

DNS & Load Balancing

A load balancing configuration allows our authoritative DNS servers to distribute requests across various servers or CNAMEs. Five key steps during this process are described below.

  1. In response to a client's action (e.g., requesting a web page), an application submits a DNS query to a recursive DNS server.
  2. A recursive DNS server forwards the DNS query to the appropriate authoritative name server (i.e., Route). The appropriate authoritative name server is determined via root and top-level domain name servers.
  3. A Route name server provides an answer to the DNS query. In this example, it will resolve a domain to an IP address according to your load balancing configuration.
    • Address Records: The Route name server will proportionately resolve DNS queries to each address record in the group. The proportion of requests that will be resolved to each address record is defined by its weight.
    • CNAME Records: The Route name server will proportionately resolve DNS queries to each CNAME record in the group. The proportion of requests that will be resolved to each CNAME record is defined by its weight. After which, the chosen CNAME record will be resolved to an address record according to its DNS configuration.
  4. A recursive DNS server caches the response according to the TTL (e.g., 300 seconds) and forwards it to the client’s application.
  5. The client’s application uses the response to fulfill the request (e.g., direct an HTTP GET request to the site's IP address).

The following illustration depicts how requests are load balanced between three different servers.

The manner in which requests will be distributed between the above servers is determined by the weight assigned to each server. More heavily weighted servers (i.e., servers that have been assigned a larger value) will receive more requests than servers that have been assigned a lower weight. The following illustration depicts a load balancing configuration that contains three servers. One of the servers has been assigned a lower load balancing weight than the other two. As a result, less traffic is sent to it.

It is important to note that proportion of traffic that will be sent to a server/CNAME can be calculated through the following formula:

In the above illustration, two servers were assigned a weight of 20 and one server was assigned a weight of 10. The total weight for that load balancing group is 50. This value is calculated by summing the weight assigned to each server (20 + 20 + 10 = 50). The following table uses the above formula to calculate the percentage of traffic that will be sent to each server.

Server Weight Calculation Traffic Percentage

A

20

(20/50) * 100

40%

B

20

(20/50) * 100

40%

C

10

(10/50) * 100

20%

Total:

50

Total:

100%

The following illustration demonstrates how traffic is redistributed among the remaining servers when a server is removed from a load balancing configuration.

Our health check system will automatically stop directing traffic to a server when it determines that it is unhealthy as defined by your configuration.

In the above illustration, our DNS service stopped serving traffic to a server that was previously receiving 40% of total traffic. This traffic must now be redistributed proportionally among the remaining two servers. We accomplish this by recalculating the traffic percentage using the new total weight value. The new total weight value, which is 30, can be calculated by summing the weight of all active servers in the configuration (20 + 10). The following table uses the above formula to calculate the percentage of traffic that will be sent to each server.

Server Weight Calculation Traffic Percentage

A

0

(0/30) * 100

0%

B

20

(20/30) * 100

66.67%

C

10

(10/30) * 100

33.33%

Total:

30

Total:

100%

In summary, we can make the following conclusions: