What a CDN Does
A Content Delivery Network serves content from geographically close edge nodes, dramatically reducing latency. A request from New York to a London origin server might take 200ms round-trip. The same request served from a local edge node in New York takes 20ms. Beyond latency, CDNs offload the origin server – a popular asset cached at edge nodes serves millions of requests without touching the origin.
Edge Node Architecture
CDNs deploy Points of Presence (PoPs) in major cities worldwide. Each PoP contains dozens of servers with large SSD caches, typically 10-100TB of storage per location. PoPs connect to local Internet Service Providers via peering agreements, allowing traffic to stay on fast local networks rather than traversing the public internet backbone. Cloudflare operates 310+ PoPs; Akamai operates 4,000+.
Cache Hierarchy
CDNs use a three-tier cache hierarchy:
- L1 – Edge cache: The PoP closest to the user. First stop for every request.
- L2 – Regional cache / mid-tier: A larger cache serving a region of multiple L1 PoPs. When an L1 misses, it checks L2 before going to origin.
- L3 – Origin server: The actual application server. Only hit when both L1 and L2 miss.
The L2 mid-tier is critical at scale. Without it, every L1 miss hits the origin directly. With hundreds of PoPs, a cache miss for a moderately popular asset could generate thousands of concurrent origin requests (a “thundering herd”). The L2 absorbs most of these misses, reducing origin connections from thousands to tens.
Cache Key Design
The cache key determines whether a request hits an existing cached entry. A naive cache key is just the URL. In practice:
- URL normalization:
example.com/image.jpgandexample.com/image.jpg?should map to the same key. Normalize before hashing. - Vary header: If the origin returns
Vary: Accept-Encoding, cache separate copies for gzip vs brotli vs uncompressed. The Vary header fields become part of the cache key. - Query parameters: Include relevant query params, exclude tracking params like
utm_source. Most CDNs let you configure which params affect the cache key. - Host header: Always included – different domains on the same CDN should have separate caches.
Cache Invalidation
Three mechanisms to control cache freshness:
- TTL-based expiration: Origin sets
Cache-Control: max-age=3600. CDN caches the response for 1 hour, then re-fetches. Simple but stale content can persist until TTL expires. - Purge API: CDN exposes an API to immediately invalidate specific URLs or URL patterns. Use this when you publish updated content and cannot wait for TTL. Purge propagates across all PoPs, typically within seconds.
- Surrogate keys / cache tags: Tag cached responses with logical group names (e.g.,
Surrogate-Key: product-123 category-shoes). Purge all entries with a given tag in one API call. Useful for CMS deployments where one content update affects hundreds of URLs.
Content Routing
Getting users to the nearest PoP requires intelligent routing:
- Anycast DNS: The CDN’s nameservers return the IP of the closest PoP based on the resolver’s location. The user’s DNS resolver (often geographically close to the user) gets a different answer than a resolver in another country.
- BGP anycast: Multiple PoPs advertise the same IP prefix via BGP. Internet routers automatically send traffic to the topologically nearest PoP. Used by Cloudflare for their anycast network.
- GeoDNS: DNS responses vary by the geographic region of the requesting resolver. More explicit than BGP anycast – specific IP ranges map to specific PoPs.
Dynamic Content
Dynamic content (personalized pages, API responses) is typically non-cacheable. CDNs still add value for dynamic content:
- TCP connection optimization: Edge nodes maintain persistent connections (connection pools) to the origin. User-to-edge TCP handshake is fast (nearby); edge-to-origin connection is already established.
- TLS termination at edge: TLS handshake happens between user and edge node (low latency). The edge-to-origin connection may use a pre-established TLS tunnel. Eliminates multiple round-trips for TLS negotiation.
- Protocol optimization: CDNs use HTTP/2 or HTTP/3 between user and edge even if origin only supports HTTP/1.1.
Origin Shield
Origin shield is a designated mid-tier node that acts as the single point of contact with the origin server. Configuration:
- All edge cache misses route to the origin shield rather than directly to origin.
- Origin shield has its own large cache. Many requests that miss at the edge hit the shield cache.
- Only shield-cache misses reach the actual origin server.
Result: Instead of 300 PoPs each making independent requests to origin on a cache miss, only the single origin shield node contacts origin. Origin connections drop from hundreds to single digits for most traffic patterns. Trade-off: adds one extra network hop for cache misses routed through the shield.
Cache Hit Rate
Cache hit rate is the primary performance metric for CDN efficiency:
- Static assets (images, CSS, JS): Target 90%+ hit rate. These rarely change and have long TTLs.
- Semi-dynamic content (product pages, articles): Target 40-60%. Shorter TTLs or surrogate-key invalidation keeps content fresh.
- Fully dynamic (user-specific, real-time): 0% cache – served from origin through CDN for network benefits only.
Factors that increase hit rate: longer TTL, broader cache key scope (fewer variations), popular content (power-law distribution means top 1% of content gets 90% of requests), larger cache size at edge.
Scale Numbers
Reference numbers for system design interviews:
- Cloudflare: Handles ~10% of all internet requests, operates 310+ PoPs globally, network capacity of 140 Tbps.
- Akamai: 4,000+ PoPs, serves 15-30% of all web traffic.
- Typical edge server: 10 Gbps NIC, 100TB SSD cache, serves 50,000+ requests/second.
- Cache miss penalty: 10-200ms depending on origin distance; cache hit: 1-10ms from nearby edge node.
Cloudflare builds CDN infrastructure at global scale. See system design questions for Cloudflare interview: CDN architecture and edge computing.
Netflix Open Connect CDN delivers streaming content globally. See system design patterns for Netflix interview: CDN and video delivery system design.
Vercel uses edge CDN for frontend performance. See system design patterns for Vercel interview: edge CDN and frontend delivery design.
See also: Scale AI Interview Guide 2026: Data Infrastructure, RLHF Pipelines, and ML Engineering
See also: Anthropic Interview Guide 2026: Process, Questions, and AI Safety