SelfTech

18 October 2026 · 6 min read

Anycast is a routing policy, not a magic wand

Anycast is one of those words that makes a design sound more sophisticated than it is. The idea is simple: announce the same IP prefix from several locations, let BGP pick the closest one, and let the network do the traffic engineering for you. It works remarkably well — until it doesn't, and then it fails in ways that are hard to see from a dashboard.

What anycast actually does

With anycast, every router on the path makes a local decision based on BGP. A user in Frankfurt reaches the Frankfurt instance; a user in Singapore reaches Singapore. No global load balancer, no DNS trickery, no GeoIP database that is wrong half the time. For connectionless protocols such as DNS, that is a very good fit: a query is a single packet, and the next query can land somewhere else without anyone noticing.

It also gives you a crude but effective denial-of-service mitigation. An attack against the anycast address is spread across every location that announces it. The attacker has to overwhelm all of them at once, or find a path that concentrates traffic on one. That is not the same as being immune, but it raises the cost.

And it gives you redundancy. If one site disappears, BGP withdraws its route and the other sites keep serving. In theory. In practice, the withdrawal has to propagate, the remaining sites have to absorb the load, and any long-lived connections to the dead site are still dead.

The part nobody tests

Anycast is not a load balancer. It does not know how many connections a site is holding, and it cannot move an existing TCP connection to another site. When a route changes, the packets of a live connection can start arriving at a different instance. That instance has never seen the connection. The result is a reset, a stall, or a very confused application.

This is why anycast works best for short, stateless exchanges and worst for long-lived sessions. If you are running QUIC, TLS with session resumption, or a database protocol over anycast, you need to think carefully about connection affinity and about what happens when the path changes. "BGP will handle it" is not a failure plan.

The other classic mistake is assuming that the nearest route is the best route. BGP chooses based on policy, not latency. A path through a transit provider with a short AS path can be slower than a longer path with better peering. And "nearest" from the perspective of a router in Amsterdam is not necessarily nearest for a mobile user in Warsaw.

Anycast gives you a topology. It does not give you a health check, a load balancer, or a rollback plan.

A checklist that has saved me time

None of this makes anycast a bad idea. It makes it an infrastructure decision with a specific shape. Use it where the protocol is stateless, the failure modes are understood, and you have actually tested the withdrawal path. The magic is in the routing policy, and routing policies have consequences.