How does DNS-based global load balancing route users to the nearest data centre?
The DNS service answers with a different IP depending on where the user is, which server is healthy, or latency measurements. Users in Mumbai get the Mumbai address, users in London get London's.
Explain it simply
When your browser asks for api.example.com, DNS replies with an IP address. A smart DNS (GeoDNS or a global traffic manager) does not return the same answer to everyone.
It can choose the answer by:
- Geography: the resolver's location maps to the nearest region.
- Latency: it picks the region with the lowest measured response time.
- Health: if a region fails health checks, its IP is dropped from answers.
- Weights: send 10% of traffic to a new region for a gradual rollout.
Limits to mention:
- DNS answers are cached for the TTL, so failover is not instant; keep TTLs short (30 to 60 seconds) for critical records.
- DNS sees the resolver's location, not always the user's.
- It balances between regions; inside each region a normal load balancer spreads traffic among servers.
Anycast is an alternative: the same IP is announced from many places and the network routes to the closest one.
Example
Domain: shop.example.in with servers in Mumbai and Frankfurt.
User in Pune -> DNS returns 103.0.0.10 (Mumbai)
User in Berlin -> DNS returns 85.0.0.20 (Frankfurt)
Mumbai fails check-> everyone gets 85.0.0.20 once cached answers expire (TTL 60 s)What to say in the interview
"Global load balancing uses DNS that returns region-specific IPs based on geography, latency, health and weights. Failover speed is bounded by the TTL. Within a region, a regular load balancer takes over; anycast is another way to reach the nearest site."