POPs and anycast — one IP, many doors

Every POP advertises the same IP; the internet's BGP routing fabric — not a CDN dispatcher — delivers each user's packets to the topologically-nearest POP.

Previously

Edges only help if users actually land on a nearby one — so how does a user in Sydney find Sydney's edge with no load balancer in the middle?

Scene 03

POPs and anycast — one IP, many doors

  1. Watch
  2. Try it
  3. Predict
  4. Capture
ANYCAST · one IP, many doorsadvertised IP: 104.16.0.16 POPs · 1 usersISP15 msPOPLA104.16.0.1AS·5POPFrankfurt104.16.0.1AS·2POPSydney104.16.0.1AS·1POPSão Paulo104.16.0.1AS·6POPSingapore104.16.0.1AS·3POPMumbai104.16.0.1AS·1user · SydneyPOP (anycast IP)chosen POP (shortest BGP path)ISP / transit hopEvery POP advertises 104.16.0.1; the user's ISP picks the shortest BGP path.
Every POP advertises the SAME IP (104.16.0.1). The user's ISP — not the CDN — picks the one with the shortest BGP path. The chosen POP is ringed.
What to watch for

A user in Sydney fires a request to 104.16.0.1. Notice every POP on the map advertises the same IP. The user's ISP picks the shortest BGP path — that's the Sydney POP, ~15 ms away.

Implementation

Highlighted lines are the ones running in the diagram right now.

AuthoritativeDNS.resolve
every user gets the SAME IP — there is no per-region answer
def resolve(name):
# cdn.example.com -> 104.16.0.1 for EVERYONE
# no geo-IP lookup, no per-region answer
return ANYCAST_VIP # 104.16.0.1
ISPRouter.routePacket
BGP picks the shortest AS-path to the anycast prefix
def routePacket(pkt):
# bgp_table[prefix] -> list of (nextHop, asPath)
routes = bgp_table[pkt.dstPrefix] # 104.16.0.0/24
best = min(routes, key=lambda r: len(r.asPath))
forward(pkt, nextHop=best.nextHop)
# The CDN never saw this decision. Each ISP made
# it independently from its own BGP table.
POP.bgpLifecycle
a POP joins or leaves the anycast group by announcing or withdrawing the prefix
def comeOnline():
# tell upstream peers 'I have a path to 104.16.0.0/24'
bgp.announce(ANYCAST_PREFIX, asPath=[self.asn])
def goOffline():
# withdraw the route — peers stop seeing us
bgp.withdraw(ANYCAST_PREFIX)
# ISPs recompute; users land on next-shortest POP.
# No client change. No DNS change. No CDN dispatcher.

Where this sits in Build a CDN

Scene 03 of 13, in the Edge basics act — The request journey, origin pain, an edge near each user, POPs and anycast.. Every POP advertises the same IP; the network's BGP routing fabric, not a CDN dispatcher, picks which edge each user reaches.

Up next. The user is now reaching a nearby POP — but how long does that POP hold the cached copy before checking origin again?

All 13 scenes in Build a CDN · Every curriculum

Built with Arqly
Every scene in Build a CDN builds on the one before it.All 13 Build a CDN scenes