DNS load balancing doesn’t just spread traffic; it actively orchestrates your users’ journeys to your services.

Let’s watch it in action. Imagine you have two web servers, web1.example.com and web2.example.com, both serving the same content but with different capacities. A basic round-robin setup might look like this in your DNS zone file:

@   IN  A   192.0.2.10  ; web1.example.com
@   IN  A   192.0.2.11  ; web2.example.com

When a user’s DNS resolver queries for example.com, the DNS server will return both 192.0.2.10 and 192.0.2.11. The resolver, typically, will pick one. The next time a different resolver (or even the same one after its cache expires) asks, the DNS server might return them in the opposite order. This is the simplest form of load balancing: round-robin. It assumes equal capacity and doesn’t account for server health or user location.

To introduce capacity differences, we use weighted round-robin. Let’s say web1 can handle twice as much traffic as web2. We assign weights:

@   IN  TXT "web1.example.com weight 2"
@   IN  TXT "web2.example.com weight 1"
@   IN  A   192.0.2.10  ; web1.example.com
@   IN  A   192.0.2.11  ; web2.example.com

This isn’t standard DNS. You’d typically use a dedicated DNS load balancing service or software that interprets these TXT records or has its own configuration syntax. The idea is that for every one request sent to web2.example.com (weight 1), two requests will be sent to web1.example.com (weight 2). The DNS server advertises the IP addresses in an order influenced by these weights.

Geo-based routing takes this further. Imagine you have servers in North America and Europe. You want users in North America to hit North American servers, and users in Europe to hit European servers, to minimize latency. Your DNS configuration would involve different IP addresses returned based on the geographic origin of the DNS query.

A simplified conceptual view might look like this (actual implementation varies wildly by DNS provider):

North America DNS View:

@   IN  A   203.0.113.5  ; NA web server 1
@   IN  A   203.0.113.6  ; NA web server 2

Europe DNS View:

@   IN  A   198.51.100.10 ; EU web server 1
@   IN  A   198.51.100.11 ; EU web server 2

When a DNS resolver in New York queries for example.com, the DNS server, recognizing the query is from North America, returns the NA IPs. When a resolver in Berlin queries, it gets the EU IPs. This is often achieved by having geographically distributed DNS servers, each serving a different set of IP addresses based on their own location.

The core problem DNS load balancing solves is distributing incoming requests across multiple instances of an application or service to improve performance, availability, and scalability. Without it, a single server becomes a bottleneck. By leveraging DNS, you can direct traffic away from overloaded or unhealthy servers, or simply spread it out to prevent any single point of failure from taking down your entire service.

Internally, most sophisticated DNS load balancing services maintain a pool of IP addresses for a given hostname. When a query arrives, the service doesn’t just pick an IP randomly. It consults a set of rules:

  1. Health Checks: Is the target server actually responding? If not, it’s removed from the pool.
  2. Weights: If weights are configured, how do they influence the probability of selecting an IP?
  3. Geo-location: Where is the query coming from? Direct it to the nearest or most appropriate server cluster.
  4. Round-Robin/Randomization: Within the eligible pool, how is the final selection made?

The exact levers you control depend on your DNS provider. They might offer a web interface where you input IP addresses, assign weights, and define geo-targeting rules. Or, you might interact via an API. Some advanced DNS providers allow you to set up "failover" records, where a secondary IP is only served if the primary IP fails a health check.

The surprising thing about DNS load balancing is how much power it gives you at the very edge of the network, before traffic even hits your infrastructure. It’s not just about picking an IP; it’s about influencing routing decisions based on real-time server health, geographic proximity, and even custom logic you define. Many assume DNS is static, but modern DNS load balancing is dynamic and intelligent.

The next concept you’ll likely grapple with is how to ensure your DNS load balancer itself is highly available and doesn’t become the single point of failure.

Want structured learning?

Take the full Dns course →