We use analytics cookies.We use cookies to analyze site traffic and improve your experience.
Loading...
2 system design questions lean on this idea. Each walks through the full answer.
System Design Masterclass · Load Balancing Proxies
Free preview: the first 2 parts of this 11-part lesson.
Already bought the course? Sign in to read the whole lesson.
this lesson is part of
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design courseread the rest of this lesson in
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design coursein Load Balancing Proxies
This lesson is part of the full System Design Masterclass. Unlock it along with 769 other lessons for a one-time payment.
One-time payment by card or PayPal
Get Lifetime AccessOne-time payment: UPI, card or netbanking
Get Lifetime Access18 Foundation lessons are free, no payment needed. Try them now
You probably assume an IP address identifies one machine. For unicast that is true. Anycast is what happens when several machines in different countries all announce the same address and every one of them is telling the truth.

There is no anycast packet, no anycast header and no anycast flag. Your packet is ordinary unicast with an ordinary destination address.
What is unusual is the announcement. Each site runs BGP and advertises the same prefix, so routers across the internet see several paths to it and each picks one.
That is worth stating precisely because it is the property everything else follows from: anycast is invisible from the endpoint. You write no special code, you open no special socket, and you cannot rely on two packets reaching the same machine.
You will read that the routing "picks the nearest server, typically the shortest path or lowest ". The first half is a useful approximation. The second half is not true, and the difference explains most of what is surprising about anycast in practice.

The selection is policy first and topology second. Local preference is set by the network doing the selecting, for its own commercial reasons, and it wins outright over everything below it.
AS path length counts networks crossed, and one network can be a continent wide.
So the honest sentence is that BGP picks the most preferred announcement, and preference is somebody's policy. That is not a quibble, and it is measurable.

Both providers answered from the site their own routing considered nearest, and they disagreed about where that was, by a factor of four in connect time.
Neither is misconfigured. Each site genuinely is the closest one in that provider's routing, and the routing is a different question for each of them.

If BGP selected on latency these two would agree. They do not, because it selects on policy and path length.
This is exactly why serious anycast operators measure real latency per network and adjust their announcements to steer traffic, rather than trusting the outcome to be optimal.

Every site serves whoever the network sends it, which is nobody's deliberate choice. The boundary between two catchments can be nowhere near the geographic midpoint, and often is not.
It also shifts on its own, when any network between you and the provider changes its policy.
That makes capacity planning genuinely hard. A routing change at somebody else's network can double the load on one of your sites overnight, and nobody will tell you it is coming.
It is easy and good
“It is really nice and good Please join the course”