Web Performance, Caching & CDNs

anycast

/ ANY-cast /

Imagine a hotline number that is the same everywhere — 1-800-HELP — but your call is automatically routed to whichever call center is nearest to you. You dial one number; the phone network decides which physical office answers. Anycast is that idea for IP addresses: one and the same IP address is announced from many locations at once, and the Internet's own routing delivers each packet to the nearest copy. Several physical servers share a single address, and you reach whichever one is closest in network terms.

How can one address live in many places? Routing makes it work. Each location running an anycast service advertises the same IP prefix into Internet routing (via BGP). Every router, following its normal best-path logic, ends up forwarding packets bound for that address toward the topologically closest announcement. So a user's packets are guided to the nearest instance without the user or their software doing anything special — the address is unicast-shaped (one destination), but it resolves to one of many identical nodes. If one site fails and withdraws its announcement, routing simply steers traffic to the next nearest site, giving built-in resilience.

Why it matters: anycast is one of the two main ways a CDN (or a DNS service) sends you to a nearby edge — the other being DNS-based redirection. Anycast is fast and automatic and self-heals during outages, which is why it underpins the DNS root servers and big public resolvers. Its honest limits: it routes by network distance, not necessarily geographic distance or current load, and it works most naturally for stateless or short request-response traffic (like DNS), because a long-lived connection could occasionally be re-steered to a different node if routing changes mid-session — something engineers design carefully around.

A public DNS resolver answers at 1.1.1.1. That single address is announced from hundreds of cities; a user in Lagos and one in Lima both query 1.1.1.1, yet each is answered by a server a few milliseconds away, thanks to anycast routing.

One address, many nodes: routing picks the nearest copy for you.

Anycast picks the nearest node by routing metrics, not by who is least loaded or truly closest in miles. And it is not multicast (one-to-many delivery): an anycast packet still goes to exactly one destination — just whichever announcement is nearest.

Also called
IP anycast任播任意播送