diagram.mmd — flowchart
Anycast Routing flowchart diagram

Anycast is a network addressing and routing method in which a single IP address is assigned to multiple servers in different geographic locations, and the internet's routing infrastructure (BGP) automatically directs traffic to the topologically nearest instance.

Anycast is distinct from unicast (one sender, one receiver), multicast (one sender, many receivers), and broadcast (one sender, all on segment). In anycast, many servers share one IP, but each individual packet is delivered to exactly one of them.

BGP Advertisement: Each anycast site advertises the same IP prefix (e.g., 203.0.113.0/24) via BGP to its upstream providers. The internet's BGP routing tables end up with multiple paths to the same prefix. Routers along the path select the route with the lowest cost (AS path length, local preference, etc.) — which typically corresponds to geographic proximity.

Client Routing: When a client sends a packet to the anycast IP, their ISP's routers forward it along the BGP-selected path toward the nearest advertising site. The client has no knowledge of anycast — it simply uses the IP address.

Use Cases: Anycast is foundational for CDN edge networks (Cloudflare, Fastly), public DNS resolvers (1.1.1.1, 8.8.8.8), DDoS mitigation (traffic is absorbed across all PoPs simultaneously), and root DNS servers.

Failure Handling: If a PoP fails and withdraws its BGP advertisement, traffic naturally reroutes to the next-nearest PoP within BGP convergence time (seconds to minutes). This provides geographic redundancy without explicit failover configuration.

Limitation: Anycast routes individual packets, not connections. TCP connections can break if a client's path changes mid-connection (e.g., due to BGP route changes). This is why QUIC/UDP is better suited than TCP for anycast deployments at scale.

Free online editor
Edit this diagram in Graphlet
Fork, modify, and export to SVG or PNG. No sign-up required.
Open in Graphlet →

Frequently asked questions

Anycast is a network addressing method where a single IP address is assigned to multiple servers in different geographic locations. The internet's BGP routing infrastructure automatically directs each client's traffic to the topologically nearest instance sharing that address.
Each anycast site advertises the same IP prefix via BGP to its upstream providers. Routers accumulate multiple BGP paths to the same prefix and select the lowest-cost route — usually the geographically nearest site. When a client sends a packet to the anycast IP, it travels along the BGP-optimal path to whichever site is closest at that moment.
Anycast is ideal for globally distributed services that need latency minimization without client-side configuration: CDN edge networks, public DNS resolvers (1.1.1.1, 8.8.8.8), DDoS mitigation infrastructure, and root DNS servers all rely on anycast to absorb traffic across many PoPs simultaneously.
Unicast sends packets from one source to exactly one specific destination. Anycast uses the same IP address on multiple servers, and the network routes each packet to whichever instance is nearest. Multicast sends one copy to a group of subscribed receivers, while broadcast sends to every device on a segment. Anycast is the only model where the routing infrastructure — not the application — selects the destination.
mermaid
flowchart TD IP([Anycast IP: 203.0.113.1\nAdvertised from all PoPs]) IP --> BGP{BGP routing\ndetermines nearest PoP} BGP --> PoPUS[PoP: US-East\nAdvertises 203.0.113.0/24] BGP --> PoPEU[PoP: EU-West\nAdvertises 203.0.113.0/24] BGP --> PoPAP[PoP: Asia-Pacific\nAdvertises 203.0.113.0/24] ClientUS([User in New York]) -->|Routes to nearest| PoPUS ClientEU([User in London]) -->|Routes to nearest| PoPEU ClientAP([User in Tokyo]) -->|Routes to nearest| PoPAP PoPUS --> Serve1[Serve request\nfrom US-East] PoPEU --> Serve2[Serve request\nfrom EU-West] PoPAP --> Serve3[Serve request\nfrom Asia-Pacific] PoPUS -->|PoP failure| Withdraw[Withdraw BGP prefix] Withdraw --> Reroute[Traffic reroutes to\nnext-nearest PoP]
Copied to clipboard