Back to 20 Concepts
scalingIntermediate

Content Delivery Networks (CDNs), Anycast & Edge Computing

CDNs cache static assets and execute serverless edge compute at hundreds of Points of Presence (PoPs) worldwide. BGP Anycast routes client DNS/TCP requests to the topologically nearest physical data center.

Intuitive Mental Model

The Global Franchise Bakery: Instead of shipping every croissant from Paris to Tokyo (200ms latency), the bakery builds 300 neighborhood franchise stores worldwide, delivering warm croissants in 5 milliseconds.

Architecture Blueprint & CodeProduction Standard
// BGP Anycast Routing:
// Single IP address (e.g. 1.1.1.1) announced by 300+ edge data centers.
// Internet BGP routers automatically route packets to the nearest geographic PoP.

Key Architectural Takeaways

  • Origin Shielding: Reduces origin server bandwidth and load by 95% via edge cache hits.
  • Edge Compute (Cloudflare Workers / Vercel Edge): Runs authentication and A/B testing at the edge with <10ms latency.
Common Architectural Pitfall

Forgetting Cache-Control header directives on dynamic API endpoints, causing CDNs to serve stale user-specific data to all visitors.

Production Best Practice

Set Cache-Control: private, no-store on sensitive user API responses.