Load BalancingGlobal Load BalancingMedium⏱️ ~3 min

DNS based GSLB vs Anycast Edge Proxy

DNS-Based GSLB

DNS-based GSLB (Global Server Load Balancing) returns different IP addresses to different users based on policies like geographic proximity, measured latency, or weighted capacity. When a user queries example.com, the authoritative DNS server evaluates the resolver location and returns the IP of the nearest healthy region. This approach is simple and cheap, scaling to handle billions of queries per day with minimal infrastructure. No special network setup required; you just configure your DNS provider with health checks and routing policies.

DNS Caching Limitations

The critical limitation is failover speed. DNS responses are cached by resolvers according to TTL (Time To Live) values, typically 20-60 seconds in production. When a region fails, users whose resolvers cached the old answer continue hitting the dead region until TTL expires. Even worse, some corporate or ISP resolvers ignore low TTLs and cache for minutes or hours. Health checks from multiple vantage points every 10-30 seconds detect failures quickly, but the DNS caching layer adds unavoidable failover latency of tens of seconds to minutes.

Anycast Edge Proxies

Anycast takes a different approach. One global IP address is announced via BGP (Border Gateway Protocol, the routing protocol that exchanges routes between networks) from many edge PoPs (Points of Presence) worldwide. Users naturally reach the nearest edge due to BGP routing, which then forwards requests to the best backend region. This achieves sub-second failover when backend pools change because the edge handles routing without DNS involvement. The edge can make HTTP-aware decisions: routing based on request headers, maintaining connection state through consistent hashing, and reusing TLS sessions to reduce handshake overhead.

Anycast Operational Complexity

The trade-off is operational complexity and cost. Running a global Anycast network requires: physical presence in hundreds of locations, BGP peering relationships with ISPs, sophisticated traffic engineering, and 24/7 operations to handle route leaks or path anomalies. A BGP misconfiguration can accidentally attract traffic meant for other networks (a "BGP hijack"). Large CDN operators run 300+ edge cities handling tens of millions RPS, often reducing end-user latency by 20-30% through smart routing around congested paths.

Choosing Between Approaches

For most companies, DNS-based GSLB is the starting point. It is simple, cheap, and sufficient when 30-60 second failover is acceptable. Add Anycast when you need sub-second failover, connection-level routing control, or when you are large enough to justify the operational investment. Many organizations use hybrid approaches: DNS-based GSLB for initial region selection, with Anycast edges within each region for fast intra-region failover.

Key Trade-off: DNS-based GSLB is simple and cheap but has 30-60+ second failover due to caching. Anycast provides sub-second failover but requires operating a global network with BGP expertise. Choose based on failover requirements and operational capability.
💡 Key Takeaways
DNS-based GSLB returns different IPs based on geography/health; simple, cheap, but 30-60+ second failover due to resolver caching
Anycast announces same IP from many PoPs via BGP; users reach nearest edge automatically; sub-second backend failover
Anycast requires 300+ PoPs, BGP peering, 24/7 ops for route anomalies; reduces latency 20-30% via smart path selection
Start with DNS GSLB; add Anycast when sub-second failover or connection-level control justifies operational complexity
📌 Interview Tips
1Explain DNS caching problem: 30s TTL but resolver caches for 5 minutes, users hit dead region for 5 minutes during failover
2Describe Anycast routing: same IP announced from Tokyo and Frankfurt PoPs, BGP routes user to nearest automatically
3Present hybrid approach: DNS GSLB for region selection, Anycast within regions for fast intra-region failover
← Back to Global Load Balancing Overview
DNS based GSLB vs Anycast Edge Proxy | Global Load Balancing - System Overflow