Anycast Routing
Anycast announces the same IP address from many locations worldwide so routing sends each user to the nearest healthy node, collapsing latency and containing regional failures.
Definition
Anycast is an addressing strategy where one IP is advertised from multiple data centers and BGP directs each client to the topologically closest announcement. Traffic shifts automatically when a node withdraws its route, giving geographic latency spread and regional failover without per-client DNS tricks.
Context and scope
The backbone of public DNS resolvers and CDNs, DDoS absorption through distributed sinks, and global API edges. Contrasted with unicast-plus-GSLB approaches that steer via DNS.
Common misconceptions
- Anycast is a load balancer — routing spreads traffic topologically; it has no notion of server load or health beyond route presence
- It works at the application layer — it operates on IP routing; stateful session affinity becomes a hard problem
- Any application can be anycast — protocols sensitive to asymmetric paths, such as TCP on congested links, need careful engineering
Anti-patterns
- Anycasting a stateful service and losing sessions whenever BGP reroutes mid-connection
- Withdrawing routes during a software rollout and shoving all regional traffic onto neighbors at once
- Expecting even distribution — BGP sends traffic by topology, so hot spots follow internet geography
Related concepts
Related examples
Authoritative source
https://www.cloudflare.com/learning/cdn/glossary/anycast-network/
What it is
The same IP lives in dozens of places at once. Border routers pick the shortest path to whichever node announces it, so a user in Tokyo lands in Tokyo and a user in Sao Paulo lands nearby. When a node dies, its route withdrawal reroutes users within seconds.
How it works
Each site advertises the prefix via BGP; the global routing table resolves to the closest advertiser by path length, not by latency measurement. Nodes must serve identical content or be stateless, since the user may be rerouted to a different site on a new connection. DNS services exploit anycast for the query packet, which is single-shot.
When to use it
DNS, static content, DDoS scrubbing, and stateless API edges are ideal. Attack traffic also gets distributed across all sites, diluting volumetric floods. Regional capacity planning must tolerate the traffic that reroutes during maintenance or failure.
Pitfalls
Path changes mid-TCP-connection can reset state unless the protocol tolerates migration; QUIC handles it better than plain TCP. Uneven distribution follows network topology rather than business metrics, so autoscaling must be per-site. Withdraw route flapping carefully — a flapping announcement degrades globally.