Skip to content
hostcomplex

DNS Load Balancing and GeoDNS

Maarten Soetens 3 min read

How DNS Load Balancing Spreads Traffic

DNS load balancing is a method of distributing visitors across several servers by giving different IP addresses in answer to DNS queries for the same name. It works entirely through DNS: the server chooses which address to return, and the client then connects directly to that server.

The simplest form is round robin. A domain has several A or AAAA records with different addresses, and the DNS server rotates their order between answers. Clients usually connect to the first address in the list, so over many visitors the load is spread roughly evenly. Round robin does not know how busy each server is, and it does not stop sending traffic to a server that has failed.

Weighted, Geographic and Health-Checked Answers

More advanced DNS providers return answers based on rules. Weighted records send a larger share of queries to stronger servers, which is useful when machines differ in capacity or when a new deployment should receive only part of the traffic at first.

GeoDNS, also called geographic routing, returns different addresses depending on where the query appears to come from. The DNS server looks at the address of the resolver asking the question and selects a nearby data center. Because the resolver may be far from the visitor, the match is an approximation. Some resolvers share part of the client's network address to improve accuracy. The idea is related to anycast, where routing rather than DNS picks the location.

Health checks allow DNS-based failover. The provider tests each server address regularly and removes any that fail, so new answers point only to healthy servers. This gives a basic form of automatic failover without a dedicated load balancer.

Limits of DNS-Based Load Balancing

DNS load balancing has limits that matter in practice. Answers are cached, and each cache keeps an answer for as long as its TTL allows. When a server fails, visitors with cached answers keep trying it until the entry expires, so failover is slower than a health-checked load balancer placed in front of the servers. Short TTLs reduce the delay but increase the number of queries the DNS service must handle.

DNS also cannot see what happens inside a connection. It chooses a server for a name, not for each request, so a long session stays on one server even if that server becomes busy. Session handling and fine-grained traffic control belong to dedicated load balancers, which sit in front of the servers and receive the actual traffic.

A Website With Two Data Centers

A company runs its website in a data center in Europe and another in North America. Its DNS provider has GeoDNS rules that return the European address to visitors who appear to be in Europe and the American address to others. Each site has a health check, so if the European site fails, its address is withdrawn and new answers send European visitors to the American site until it recovers. Visitors who still hold a cached answer experience a delay before they reach the working site.

Frequently asked questions

Is DNS load balancing the same as a load balancer?

No. DNS load balancing chooses which address a client receives when it looks up a name, and the client then connects to that address directly. A load balancer receives the connections themselves and distributes them among servers in real time. The two are often combined, with DNS directing traffic to regional sites and a load balancer spreading it within each site.

Does GeoDNS always send users to the closest server?

Not always. GeoDNS uses the location of the resolver asking the question as a guide to the visitor's location, which is usually close but not exact. Visitors who use a distant public resolver can be matched to the wrong region, and routing rules may send traffic elsewhere for reasons such as capacity or policy. It works well for most users, but the result is an estimate.

  • Two-Factor Authentication

    Two factor authentication hosting adds a second check to control panel, domain and CMS logins. Learn which methods are strongest and why 2FA helps.

  • What Is an A Record?

    What is an A record? Learn how this DNS record maps a hostname to an IPv4 address, why domains use several A records and the root and www pattern.

  • Billing and Automation Platforms

    What is WHMCS? Learn how this commercial billing and automation platform helps hosts sell plans, collect payments and create accounts automatically.