Round-Robin DNS: When Multiple A Records Help and When They Don't
Use multiple A or AAAA records for one hostname, test each endpoint independently, and decide when you need health-aware routing.
- domains
- dns
- hosting
Round-robin DNS offers more than one address for a hostname and may vary the answer order. It can spread connections among interchangeable servers over time. DNS address rotation alone cannot tell whether an endpoint is healthy and does not make each browser choose a different server.
Put both addresses in one record set
Consider an example website with two interchangeable servers. Each server directly accepts the same HTTPS hostname. Here is the intended DNS state, using documentation addresses.
| Name | Type | Address | TTL |
|---|---|---|---|
www.example.com. | A | 192.0.2.20 | 300 |
www.example.com. | A | 192.0.2.21 | 300 |
These are two records in one resource record set. RFC 2181 §5 defines an RRset by its owner name, class and type, and says the members use the same TTL. If you also serve IPv6, test the separate AAAA record set. Two healthy IPv4 endpoints do not establish that the IPv6 endpoint works.
The IETF's round-robin history describes implementations that rotated the address order without looking at the target machines' current load. The ordering you see depends on your authoritative provider, resolver and client. Compare the set of returned addresses even when the display order varies.
Test discovery and reachability separately
On infrastructure you control, query the authoritative nameserver with dig @ns1.example.net www.example.com A +norecurse. Compare its answers with the answers from the resolver your users rely on. If the authoritative answers are correct but a resolver serves the previous set, check the TTL before changing the records again.
Then send a request to each endpoint while retaining the intended hostname. For the first example address, the command would be curl --resolve www.example.com:443:192.0.2.20 https://www.example.com/. Repeat with the second address. Check the certificate, HTTP response and one known page on each server. Testing a bare IP would bypass the hostname used for certificate and virtual-host selection.
If the second address returns an error, you have located an endpoint problem even if the DNS response is correct. A successful request through the normal hostname may have reached only the first address.
Choose how you want failures to behave
At the point when a plain DNS provider stops returning an address, a resolver or client may still have a cached answer. Existing connections also have their own lifetimes. A lower TTL can shorten some cache lifetimes after the change but does not drain connections or enforce evenly distributed requests.
Use ordinary multiple records if the services are interchangeable and the application can tolerate that failure behavior. If you need failed addresses removed from new DNS answers, choose a health-aware policy and verify how the provider handles the all-unhealthy case. For example, the Route 53 multivalue policy documents how it selects records based on health and what happens when every record is unhealthy.
If you need request-level health checks, connection draining, or session routing, use a load balancer designed for those jobs. Keep application data and sessions consistent across the endpoints whichever policy you choose.
