28 September 2026 · routing
Anycast is a routing trick, not magic
Anycast is often described as if the network somehow knows which server is closest. It does not. The network knows which route it prefers, and that preference is the result of BGP path selection, local policy and a fair amount of history.
When the same prefix is announced from many locations, each network picks one of those announcements. Most of the time the choice correlates with topology, so users land on a nearby copy. Occasionally it does not: a regional ISP prefers a path that crosses an ocean because a transit provider advertises a shorter AS path.
Consequences
Anycast gives you redundancy and a rough approximation of locality. It does not give you a guarantee that a user stays on the same server for the whole session. If your application keeps state on the node, a routing change is a user-visible event.
The fix is not a better anycast trick. The fix is to make state external and to make the service indifferent to which node answers.
Things that surprised me
- Two users in the same city can land on different continents.
- A prefix can move for a single /24 without any visible change in latency.
- BGP communities are documentation that the router actually reads.