Topic 4.4
BGP, Anycast & CDNs
In one line
BGP is how independent networks tell each other which address ranges they can reach; anycast announces the same addresses from many places so users reach the nearest; CDNs use both to serve content close to users.
Key ideas
- 01
The internet is made of AUTONOMOUS SYSTEMS (ASes): networks run by one organisation (ISPs, clouds, large companies), each with an AS number. BGP (Border Gateway Protocol) is how ASes announce 'I can reach these prefixes' to their neighbours, and choose paths based on policy.
- 02
BGP runs on trust and policy, so mistakes spread. Famous incidents: Pakistan Telecom accidentally hijacking YouTube's prefixes (2008), and Facebook withdrawing the routes to its own DNS servers (October 2021), which took Facebook, Instagram, and WhatsApp offline for about six hours. RPKI is the modern defence against invalid announcements.
- 03
ANYCAST: the SAME IP prefix is announced from many locations; BGP routes each user to the topologically nearest one. Public DNS resolvers (
1.1.1.1,8.8.8.8), root DNS servers, and CDN edges all use anycast, which gives low latency and natural DDoS absorption. - 04
CDNs (CloudFront, Cloudflare, Akamai, Fastly) run hundreds of edge locations. The edge terminates the connection close to the user, serves cached content, and reuses warm connections back to your origin, reducing latency even for uncached, dynamic requests (AWS course, Topic 7.2).
- 05
For most DevOps engineers, BGP matters indirectly: Direct Connect and VPN setups use it (AWS course, Topic 3.4), Kubernetes CNIs like Calico and Cilium can announce pod or service IPs over BGP to physical networks, and understanding it explains many large public outages.
Code & diagrams
curl -sI https://www.cloudflare.com | grep -i cf-ray # which edge POP served you (e.g. ...-BOM = Mumbai)
curl -sI https://d111111abcdef8.cloudfront.net | grep -i -E 'x-amz-cf-pop|x-cache'
whois -h whois.radb.net 1.1.1.0/24 | grep -i origin # which AS originates a prefixExplain it without notes
How can the same IP address, like 1.1.1.1, be served from dozens of cities at once?
Practice
Why does a CDN speed up even responses that can't be cached, like a personalised API call?
Trade-offs
- ↔
Anycast and CDNs give global performance and DDoS resilience but make debugging harder (different users hit different servers) and add a critical dependency: a CDN or BGP misconfiguration can take a whole site offline.
Done when you can
I can explain what BGP and autonomous systems are.
I understand anycast and why DNS resolvers and CDNs use it.
I know how a CDN reduces latency for cached and uncached content.