DNS load balancer

Load balancing via DNS is achieved by assigning more than one IP address to the same name. For example, to balance the load on http requests for the site example.com, we would add more than one IP address, say 3, to the site. So the site can be accessed with any of the IP address.

The order in which the nameserver answers the dns query for that site is configured by setting ‘rrset-order’ in named.conf file.

For example, the configuration will return A records in round-robin order.

rrset-order {
class IN type A name “*” order cyclic;
};

Other options are,
fixed    – returns A record in the order they are defined in the zone file
random – returns A record in some random order

Here is an example of rrset-order set in cyclic way.

bash-3.00$ dig +short example.com @localhost
192.168.1.1
192.168.1.2
192.168.1.3
bash-3.00$ dig +short example.com @localhost
192.168.1.3
192.168.1.1
192.168.1.2
bash-3.00$ dig +short example.com @localhost
192.168.1.2
192.168.1.3
192.168.1.1
bash-3.00$ dig +short example.com @localhost
192.168.1.1
192.168.1.2
192.168.1.3
bash-3.00$

As you may see, the IP returned is being changed cyclically. And usually the client querying the nameserver will use only the first IP address. So by adding more than one IP address with proper TTL value, we can achieve primitive load balancing via DNS.

 

 

Both comments and pings are currently closed.

Comments are closed.