Quick revision
The short answer
With DNS-based global load balancing, the authoritative DNS service answers the same name with different addresses depending on rules such as the caller's location, measured latency, weights and the health of each region. It sees the recursive resolver rather than the user, and its answers are cached for the TTL, so shifts take at least that long and caches do not always obey. Anycast instead announces one IP address from many sites through BGP, and network routing delivers packets to the nearest site, so failover happens when a route is withdrawn, without waiting for DNS caches.
What to remember
In this answer, we saw that DNS-based global load balancing answers lookups at the authoritative server using location, latency, weight and health rules, that it sees the resolver rather than the user unless EDNS Client Subnet is sent, and that TTLs and imperfect caches set how quickly changes take effect. Anycast announces one address from many sites and lets BGP choose, giving fast failover without DNS caches, but it suits stateless or short exchanges because route changes can break long TCP connections.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
With DNS-based global load balancing, the authoritative DNS service answers the same name with different addresses depending on rules such as the caller's location, measured latency, weights and the health of each region. It sees the recursive resolver rather than the user, and its answers are cached for the TTL, so shifts take at least that long and caches do not always obey. Anycast instead announces one IP address from many sites through BGP, and network routing delivers packets to the nearest site, so failover happens when a route is withdrawn, without waiting for DNS caches.
Why this question is asked
As soon as a service runs in more than one region, something has to decide which region each user reaches. That decision affects latency for every request and how fast we recover when a region fails. Interviewers ask this to check that we understand where the decision is made and what delays it. In this answer, we will recap how a name lookup works, see how a DNS service makes routing decisions, look at the resolver problem and EDNS Client Subnet, understand TTL and caching, and then compare all of that with anycast.
1A Quick Recap: How a Name Lookup Works
When a phone wants api.example.com, it asks a recursive resolver, usually run by the internet provider or a public service. The resolver asks the root and top-level servers where example.com is served, then asks the authoritative DNS servers for example.com, the servers that hold the real records. The authoritative server answers with an address and a TTL, time to live, which says how many seconds the answer may be cached. The resolver caches it and returns it to the phone, which often caches it too.
Global load balancing with DNS works at the authoritative step. Instead of a fixed record, the authoritative service runs rules each time it answers.
2How the DNS Service Chooses a Region
The rules come in a few common kinds, and managed DNS services usually let us combine them. Geographic routing maps the caller's location to a region, for example Europe to Frankfurt. Latency-based routing uses measurements of network latency from many networks to each region and returns the fastest. Weighted routing returns regions in proportion to weights, which lets us move 10 percent of traffic to a new region and then more. Health checks run alongside all of these, and a region that fails its checks is left out of the answers.
6 messages in order. Play them, or step through them one at a time.
The decision is made once per cached answer, at the authoritative server.
Notice that the DNS service never sees the user's requests. It only decides which address the user gets, once per cache lifetime, and the user then talks to that region directly.
3The Resolver Problem and EDNS Client Subnet
There is a catch in the second message above. The authoritative server sees the address of the recursive resolver, not the address of the user. For a user of their own provider's resolver, the two are close. For a user in Singapore whose phone is set to a public resolver whose nearest site is in another country, the DNS service thinks the user is wherever that resolver is, and may send them to a distant region.
The EDNS Client Subnet extension, ECS, fixes much of this: the resolver adds a truncated part of the user's address, such as the first 24 bits of an IPv4 address, to its question, so the authoritative server can route on that instead. Not every resolver sends it, some deliberately do not for privacy, so DNS routing is always somewhat approximate.
4TTL: The Speed Limit of DNS Changes
Every answer is cached for its TTL, so when we change a decision, for example to remove a failed region, users only notice when their cached answer expires. A TTL of 30 to 60 seconds allows reasonably fast shifts but multiplies queries to our DNS service, which costs money with managed providers and adds a little lookup latency for users. A TTL of an hour makes lookups cheap but means a failed region keeps receiving traffic for up to an hour.
And caches do not always respect the TTL. Some resolvers enforce a minimum, some clients cache answers for as long as the process runs, and long-lived connections do not look up the name again at all. In practice, a DNS change with a 60-second TTL moves most traffic within a few minutes and leaves a tail that takes much longer.
5Anycast: Letting the Network Choose
Anycast takes a different approach. Instead of giving different users different addresses, we announce the same IP address from many sites through BGP, the routing protocol that connects networks on the internet. Every router picks the path it considers best to that address, which normally means the nearest site in network terms. A user in Paris and a user in Tokyo both connect to 198.51.100.1, but their packets arrive at different sites.
Failover is fast because nothing is cached at the edges: if a site fails, it withdraws its route announcement, and within seconds to a few minutes routers send packets to the next nearest site. The address never changes, so DNS TTLs do not matter. The weakness is that routing can change in the middle of a connection, and packets of an ongoing TCP connection may suddenly arrive at a site that has never seen it, which breaks the connection. That is why anycast suits stateless or short exchanges, like DNS itself, and edge proxies that terminate connections close to users and then forward to a region.
| Aspect | DNS-based | Anycast |
|---|---|---|
| Who decides | authoritative DNS rules | BGP routing between networks |
| Failover speed | TTL plus caches, minutes with a tail | route withdrawal, seconds to minutes |
| Fine control | weights, geography, latency rules | coarse, follows network paths |
| Best for | picking a region for HTTP traffic | DNS, edge proxies, short exchanges |
| Main risk | stale caches, wrong resolver location | path changes break long TCP sessions |
6Follow-up questions
Why might a user in one city be sent to a far-away region?
Usually because the DNS service routes on the resolver's location, not the user's. A user on a public resolver, a corporate resolver in head office or a VPN may appear to be somewhere else, and if the resolver does not send EDNS Client Subnet the DNS service cannot tell. Other causes are a nearer region being marked unhealthy or drained by weight, latency measurements that are out of date, or simply a cached answer from before a routing change.
Can we combine DNS routing and anycast?
Yes, and large services often do. Anycast addresses point to an edge layer near users, which terminates TCP and TLS, and the edge forwards requests to a region chosen by its own health and latency logic. The user's address never changes, so failover does not wait for DNS caches, and the edge can still apply weights and health rules per region.
7Conclusion
In this answer, we saw that DNS-based global load balancing answers lookups at the authoritative server using location, latency, weight and health rules, that it sees the resolver rather than the user unless EDNS Client Subnet is sent, and that TTLs and imperfect caches set how quickly changes take effect. Anycast announces one address from many sites and lets BGP choose, giving fast failover without DNS caches, but it suits stateless or short exchanges because route changes can break long TCP connections.
Open with
DNS-based global load balancing happens at the authoritative DNS server. When a resolver asks for our name, the DNS service applies rules: geographic location, measured latency, weights for gradual shifts, and health checks that leave failed regions out of the answer.
Then, if they want more
One subtlety is that it sees the recursive resolver's address, not the user's, so a user on a distant public resolver can be sent to the wrong region unless the resolver sends EDNS Client Subnet. The TTL says how long the answer may be cached.
A short TTL like 30 to 60 seconds lets us shift traffic faster but costs more queries, and caches do not always respect it, and long-lived connections ignore DNS entirely, so there is always a tail.
Anycast is different: we announce the same IP address from many sites via BGP, and the network delivers each user's packets to the nearest site. Failover happens when a site withdraws its route, without waiting for any DNS cache.
The weakness is that a routing change in the middle of a long TCP connection can deliver its packets to a different site and break it, so anycast suits DNS, edge proxies and short exchanges, and many setups combine anycast at the edge with regional choice behind it.
About this answer
- Last updated
- 13 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the official documentation for the version you use. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Explain how DNS-based global load balancing works, the role of TTL, and how anycast...": https://scrivio-interview-library.netlify.app/architecture/load-balancing-networking/824a51e8ab/