← Back to All Questions
Hard~55 minInfrastructure

Design Content Delivery Network (CDN)

CloudflareAkamaiFastlyAmazonNetflix

📝 Problem Description

Design a global Content Delivery Network (CDN) that caches and serves static content (images, videos, JS, CSS) from edge locations worldwide. Minimize latency by serving from geographically closest servers.

👤 Use Cases

1.
User wants to requests image so that served from nearest edge
2.
Content owner wants to uploads new content so that propagates to edge
3.
Origin wants to content changes so that cache invalidated
4.
System wants to edge cache miss so that fetches from origin

✅ Functional Requirements

  • Cache static content at edge locations
  • Route users to nearest edge
  • Handle cache misses by fetching from origin
  • Support cache invalidation/purge
  • HTTPS/TLS termination at edge
  • Support custom domains

⚡ Non-Functional Requirements

  • Latency < 50ms for cached content
  • 99.99% availability
  • Global coverage (200+ edge locations)
  • Handle 10M requests/sec

⚠️ Constraints & Assumptions

  • Edge servers have limited storage
  • Cache consistency vs freshness tradeoff
  • Must handle DDoS attacks

📊 Capacity Estimation

👥 Users
Global internet users
💾 Storage
10TB per edge location
⚡ QPS
10M requests/sec global
🌐 Bandwidth
1Tbps peak per edge
📐 Assumptions
  • 200 edge locations worldwide
  • 10TB SSD cache per edge PoP
  • 95% cache hit rate target
  • Average object size: 100KB
  • Cache TTL: 1 hour to 1 year
  • Origin fetch on miss: ~200ms

💡 Key Concepts

CRITICAL
GeoDNS
DNS returns IP of nearest edge based on user location.
HIGH
Cache Hierarchy
Edge → Shield → Origin reduces origin load.
HIGH
Cache-Control Headers
TTL and caching behavior controlled by HTTP headers.
HIGH
Cache Invalidation
Purge propagation to all edges when content changes.
MEDIUM
Anycast
Same IP announced from multiple PoPs; routing chooses nearest.

💡 Interview Tips

  • 💡Start with the CDN architecture: edge → shield → origin
  • 💡Discuss cache invalidation strategies
  • 💡Emphasize the importance of cache hit ratio
  • 💡Be prepared to discuss DNS and anycast routing
  • 💡Know the tradeoffs between push and pull CDN
  • 💡Understand how Cloudflare, Akamai, and CloudFront work