Menu

Earn Premium with Referrals

Invite your friends and earn Premium rewards through our referral program.

See how it works and start inviting friends.

Anycast at the Edge
HLD

Anycast at the Edge

One IP, everywhere — how BGP routing delivers users to nearby edges without DNS games.

The Trick

 UNICAST (normal): one IP → one physical location
 ANYCAST:          one IP announced from MANY locations;
                   internet routing (BGP) delivers each user
                   to the NEAREST announcing point

 104.16.0.1 announced simultaneously from:
   Frankfurt POP ──► European users' packets arrive here
   Tokyo POP    ──► Japanese users arrive here  
   Ashburn POP  ──► US-East users arrive here

 no DNS tricks, no redirects, no client config.
 ROUTING ITSELF is the load balancer.

Why It Wins for CDNs

 ✓ PROXIMITY AUTOMATIC: BGP prefers shortest AS-path ≈ nearest POP
 ✓ FAILOVER FREE:       POP dies → its announcements withdrawn →
                        traffic reroutes to neighbors in seconds
                        (no health-check machinery at all)
 ✓ LOAD ABSORPTION:     regional surges spill to adjacent POPs
                        naturally
 ✓ SIMPLE CLIENTS:      same hostname/IP everywhere; zero logic

The Mechanics Underneath

 each POP runs BGP with upstream providers:

 POP announces:  "reach 104.16.0.0/16 through ME"
 multiple announcements exist globally;
 routers pick best path (typically fewest hops/ASNs)

 consequences and subtleties:
 - granularity = network topology, NOT geographic distance:
   a user might reach the "wrong" city if paths say so —
   usually fine (path-short = latency-short anyway)
 - route FLAPS can move users between POPs mid-session →
   edge protocols must tolerate client migration
   (that's partly why QUIC connection-IDs matter)

Anycast + Unicast Hybrid Patterns

 pure anycast has limits; production designs blend:

 - anycast for INGRESS (user→edge): the win zone
 - unicast/DNS-GEO for REGION SELECTION when state locality matters:
     user lands at Manila edge via anycast,
     edge consults geo-DNS/config to pick their DATA region
 - weighted anycast: announce with prepends to shape traffic ratios
 
 the layering: anycast answers "which edge?",
               other layers answer "which database/region?"

Failure Behavior Worth Knowing

 POP outage sequence (automatic):
 1. POP stops announcing (BGP session down)
 2. routes withdraw within seconds-minutes globally
    (BGP convergence is fast but not instant)
 3. affected users' packets flow to next-nearest POP
 4. caches there are COLDER → brief hit-rate dip → self-heals

 vs unicast failover: no LB config, no health checks,
 no DNS TTL waiting. the internet's own machinery does it.

Interview Framing

“How do users worldwide reach one service endpoint fast?” scored answer: anycast announcement from many POPs, BGP proximity routing, automatic failover via route withdrawal, plus honest limits (topology-vs-geography granularity, mid-session POP migration). Contrasting it against DNS-geo-routing (lookup-time vs routing-time) demonstrates real networking depth — interviewers probe exactly this distinction.

My Private Notes

Notes are auto-saved locally to this device.