What is DNS balancing?

The DNS server is the first host that receives a request from a visitor and returns the IP address of the application. After that, the visitor’s browser sends an HTTP request to the application server and receives a response.

The IP address is indicated in an A domain record like this (for example):

ruhighload.com IN A 188.226.228.90

Usually one A record is indicated, therefore DNS always returns the same IP address. However, it is possible to change the given IP address. This allows you to direct different visitors to different servers from the same domain.

A-record (address record) – DNS record that allows you to map a domain name to the server IP address.

A-record contains the IP address of the server. When making a request to the server, the browser or another network program makes a request to the DNS servers, receives an IP address and sends a request to it, also transferring the domain in the headers (since there can be several sites on one server with one IP).

In the absence of A-records, HTTP access is not possible. However, if there are other entries, some domain features (such as sending and receiving email) may work.

A-record is one of the main DNS records. All providers that provide DNS zone management functions allow you to set such records for a domain.

A records only indicate IPv4 addresses. For IPv6 addresses, the AAAA record is used.

The standard domain configuration includes one A-record per domain name. There are non-standard configurations:

  • Round Robin – a single domain name is assigned several IP addresses that correspond to identical configuration servers in order to distribute the load on a highly visited service;
  • Wildcard – compares the IP address not only with a specific domain name, but also with all its subdomains. It can be used on services that provide users with N-level domain names immediately after registering a new account, such an entry looks like *.domain.net.

In addition to the main purpose, A-records are used in DNSBL systems.

To view A records, you can use the host command with the -t A option on the command line.

Round Robin

DNS allows you to specify more than one IP address in A records:

site.com IN A 220.220.220.80
site.com IN A x.x.x.x
site.com IN A y.y.y.y

# x.x.x.x и y.y.y.y — IP addresses of other frontends

In this case, different clients will receive different IP addresses when accessing our domain. This will allow you to distribute the load between several servers that serve the application.

Round Robin assumes that IP addresses will be issued in turn (first the first, then the second, etc.). However, this is not standardized anywhere, so you should not rely on it.

Domain IP addresses are cached in local DNSs. If one of the servers fails, there will be a long delay before all the caches are updated. Therefore, Round Robin should be used in conjunction with fault tolerance mechanisms.

Set a small ttl for A records to be able to quickly change them. Optimal values are a few minutes.

Geo DNS

DNS servers also allow you to give different IP addresses to clients based on their location. This is very useful for sites with a high geographic spread of visitors.

Suppose you have a significant number of visitors from the USA and Europe, and the application server is located only in Europe. Then it will be useful to make a copy of the server in the USA. When visiting visitors from the USA, send them to a server in the USA. From Europe – to a server in Europe.

This feature is used for a CDN.

Bind GeoDNS

There is a GeoDNS Patch for the popular BIND server. It allows you to specify various settings for location-based zones. As a geodatabase, Max Mind is used:

# Different records for one domain using GeoDNS.
...
view "usa" {
      match-clients { country_US; country_CA; country_MX; };
      recursion no;
      zone "ruhighload.com" {
            type master;
            file "pri/ruhighload.usa.db";
      };
};

view "other" {
      match-clients { any; };
      recursion no;
      zone "ruhighload.com" {
            type master;
            file "pri/ruhighload.other.db";
      };
};

Use DNS Round Robin to distribute the load across multiple servers. Install a small ttl, as well as check out the load balancing on the front-ends.

You can comment on the article below or ask a question on Uzabila QNA.

Top ↑

Sergei Ermilov

I create web projects, come up with ideas, develop, optimize and promote websites. The first steps in this direction were taken in 2008. If you have any ideas or want to suggest something, then write to me and my team.

Leave a Reply