Anycast: One Address, Many Destinations
Anycast networking is the routing technique that makes modern CDNs possible — a method where a single IP address is announced from multiple geographic locations simultaneously, and the network automatically routes each user to the nearest one. When you connect to Cloudflare's DNS resolver at 1.1.1.1 or Google's at 8.8.8.8, you're using anycast: those IP addresses exist in hundreds of locations worldwide, and BGP routing ensures your request reaches the closest instance. Anycast is the foundation of CDN geo-routing and DDoS protection.
What Is the History of Anycast?
Anycast's journey from theoretical concept to critical internet infrastructure spans three decades:
- 1993 (RFC 1546): Craig Partridge and colleagues at BBN Technologies published "Host Anycasting Service," the first formal description of anycast addressing. The paper proposed that multiple hosts could share the same IP address, with routing protocols selecting the nearest one.
- 1997: The DNS root server system became the first large-scale anycast deployment. The I Root Server (operated by Netnod) and the J Root Server (operated by Verisign) began using anycast to distribute DNS root service across multiple geographic locations.
- 2002: The remaining DNS root servers adopted anycast. Today, the 13 root server "letters" (A through M) actually represent over 1,700 physical server instances worldwide, all operating via anycast.
- 2004-2010: CDN providers began adopting anycast for content delivery. Cloudflare (2010) built its entire network on anycast from day one, announcing the same IP ranges from every data center.
- 2015-present: Anycast became the standard architecture for CDN, DNS, and DDoS mitigation services. Modern CDNs announce anycast prefixes from 200-300+ locations globally.
How Does Anycast Routing Work?
Anycast works by leveraging BGP's natural behavior. When multiple locations announce the same IP prefix, BGP treats them as different paths to the same destination and selects the "best" path according to its decision process — typically the shortest AS-PATH, which usually correlates with geographic proximity:
| Metric | Edge Processing | Origin Processing | Improvement |
|---|---|---|---|
| Latency (p50) | 8–15 ms | 120–300 ms | 15–20x faster |
| Cache Hit Ratio | 85–95% | N/A | Reduces origin load |
| TLS Handshake | 1–5 ms (nearby PoP) | 50–150 ms | 10–30x faster |
| Bandwidth Cost | $0.01–0.04/GB | $0.05–0.12/GB | 3–5x cheaper |
| Availability | 99.99% (multi-PoP) | 99.9% (single DC) | 10x fewer outages |
- Prefix Announcement: A CDN provider assigns the same IP prefix (e.g., 104.26.0.0/20) to servers in all its PoPs (Points of Presence) worldwide — Tokyo, London, New York, São Paulo, etc.
- BGP Advertisement: Each PoP's BGP routers announce this prefix to their peering partners and upstream transit providers. The BGP announcements from different locations carry different AS-PATHs (reflecting the local peering topology).
- Routing Convergence: ISPs worldwide receive multiple advertisements for the same prefix from different geographic origins. Their BGP decision process selects the "best" path — typically the one with the shortest AS-PATH length.
- Traffic Delivery: When a user sends a packet to the anycast IP, their ISP's router forwards it along the selected BGP path to the nearest CDN PoP. The user doesn't know (or care) which physical server receives the packet.
Why Is Anycast Essential for CDN Performance?
Anycast provides several critical advantages for content delivery:
- Automatic Geo-Routing: No application-layer routing logic is needed. BGP handles user-to-PoP mapping at the network layer, typically achieving within 1-2 hops of the true geographic optimum. DNS-based routing (the alternative) is limited by resolver location accuracy and TTL delays.
- DDoS Mitigation: An anycast IP address distributes attack traffic across all announcing locations. A 1 Tbps DDoS attack targeting an anycast address with 200 PoPs means each PoP absorbs only ~5 Gbps — manageable for a well-provisioned edge server. This is the foundation of CDN DDoS protection services.
- Instant Failover: If a PoP goes offline, its BGP routes are withdrawn within seconds. Traffic automatically shifts to the next-nearest PoP — no DNS TTL delay, no client-side retry. For anycast vs unicast CDN architectures, this is a decisive advantage.
- Simplified DNS: Instead of using GeoDNS to return different IPs for different regions, the CDN can return a single anycast IP for all users worldwide. This simplifies DNS configuration and eliminates accuracy issues with resolver-based geolocation.
What Are the Challenges of Anycast?
Anycast is not without trade-offs:
- TCP Connection Persistence: If BGP routes change while a TCP connection is active, subsequent packets may be routed to a different PoP, breaking the connection. CDN providers mitigate this with stable BGP configurations, route dampening, and ECMP (Equal-Cost Multi-Path) routing. QUIC's connection migration feature (part of HTTP/3) addresses this at the transport layer.
- BGP Convergence Time: After a PoP failure, BGP convergence (the process of all routers updating their routing tables) can take 30-90 seconds. During this period, some traffic may still be routed to the failed PoP. CDN providers use techniques like BGP Graceful Restart and pre-computed backup routes to minimize this window.
- Debugging Complexity: Because the same IP exists at many locations, traditional network debugging tools (traceroute, ping) can be confusing — a traceroute to an anycast IP from different locations will show completely different paths. CDN providers offer looking-glass tools and PoP-specific diagnostic endpoints.
- Cache Fragmentation: Since different users hit different PoPs, each PoP has its own cache. A resource cached at the Tokyo PoP doesn't help a user in London. CDN providers address this with tiered caching (a central cache layer that PoPs query before going to origin) and cache warming strategies.
Which Major Services Use Anycast?
| Service | Anycast IPs | Locations | Use Case |
|---|---|---|---|
| Cloudflare CDN | Entire network | 310+ cities | CDN, DNS, DDoS, edge compute |
| Google Public DNS | 8.8.8.8, 8.8.4.4 | 30+ countries | DNS resolution |
| Cloudflare DNS | 1.1.1.1, 1.0.0.1 | 310+ cities | DNS resolution + privacy |
| DNS Root Servers | 13 letter addresses | 1,700+ instances | DNS root resolution |
| Fastly | Entire network | 80+ PoPs | CDN, edge compute |
| AWS Route 53 | DNS infrastructure | 100+ locations | Managed DNS |