In this lesson · topic 6 of 7
Topic 6
Anycast in words
3 min read
One address, many places
With unicast, an address belongs to one machine. With anycast, many machines in different places announce the same address into the network. Routers send each packet to whichever announcement is closest by routing cost. Two users in two cities use the same address and reach different machines.
Public DNS services and large CDNs use this. A nearby site answers, and no DNS answer has to be tuned for each user.
Why it helps failover
If a site stops announcing the address, routers stop sending packets to it and use the next nearest. The change takes as long as routing needs to converge, which is usually much shorter than a TTL. No resolver cache holds the old answer, because the address never changed.
What it does not do
- It picks by routing cost, which is not always the fastest path or the nearest place.
- A route change can move a user to another site while a connection is open. A short exchange survives that. A long TCP connection may be reset, because the new site has no state for it.
- It balances by geography and not by load. An overloaded site keeps getting traffic unless it withdraws its announcement.
Anycast works well for short, stateless exchanges such as DNS queries and for fronts that can take over a connection. A common design uses both: DNS gives the name, anycast gives a stable address with fast failover, and a nearby site terminates the connection.