System Design

System Design: Designing a Content Delivery Network (CDN)

How do Netflix and Akamai serve video to millions with zero lag? A technical deep dive into Edge Caching, Request Routing, and Cache Invalidation.

Sachin Sarawgi·April 20, 2026·3 min read
#system-design#cdn#caching#edge-computing#distributed-systems#scalability

System Design: Designing a Content Delivery Network (CDN)

A CDN is a geographically distributed group of servers that work together to provide fast delivery of internet content. By caching assets (images, videos, JS/CSS) at the "edge" of the network, CDNs reduce the distance between the user and the data, significantly lowering latency.

1. Core Requirements

  • Latency: Serving content from a server closest to the user.
  • Availability: Content should be available even if the origin server is down.
  • Scalability: Handling massive spikes in traffic (e.g., a viral video).
  • Security: Protection against DDoS attacks at the edge.

2. High-Level Architecture

  • Origin Server: The source of truth where the original content is stored (e.g., S3).
  • Edge Servers (POPs): Distributed servers that cache content and serve it to users.
  • Routing System: Directs the user's request to the optimal Edge Server.

3. How Request Routing Works

When you type netflix.com/movie.mp4, how does the system pick the right server?

  • Anycast IP: Multiple edge servers share the same IP address. Routers automatically send the request to the topologically nearest server.
  • DNS Routing: The DNS server returns a different IP address based on the user's geographic location (Geo-DNS).

4. Caching Strategies: Push vs. Pull

  • Pull Model (On-Demand): The edge server only fetches content from the origin when a user requests it for the first time.
    • Pros: Efficient storage usage.
    • Cons: The first user experiences high latency (cache miss).
  • Push Model (Proactive): The origin server "pushes" content to all edge servers immediately after upload.
    • Pros: Fast for all users.
    • Cons: Wastes storage for niche content that is rarely watched.

5. Cache Invalidation: The Hardest Problem

How do you update an image that is cached on 10,000 servers?

  • TTL (Time To Live): Content expires automatically after a set time.
  • Purging: The origin server sends a "Purge" command to all edge nodes to delete a specific file.
  • Versioned URLs: Instead of updating logo.png, you use logo_v2.png. This is the most reliable way to ensure consistency.

6. Security at the Edge

A CDN is the first line of defense.

  • DDoS Protection: Edge servers can detect and block massive floods of junk traffic before they ever reach your application servers.
  • WAF (Web Application Firewall): Filtering out SQL injection or XSS attacks at the network edge.

Summary

The engineering of a CDN is about Distance. By moving data closer to the user and mastering the complexities of request routing and cache invalidation, you can build a system that delivers a global, high-performance experience to millions of users simultaneously.

📚

Recommended Resources

Designing Data-Intensive ApplicationsBest Seller

The definitive guide to building scalable, reliable distributed systems by Martin Kleppmann.

View on Amazon
Kafka: The Definitive GuideEditor's Pick

Real-time data and stream processing by Confluent engineers.

View on Amazon
Apache Kafka Series on Udemy

Hands-on Kafka course covering producers, consumers, Kafka Streams, and Connect.

View Course

Practical engineering notes

Get the next backend guide in your inbox

One useful note when a new deep dive is published: system design tradeoffs, Java production lessons, Kafka debugging, database patterns, and AI infrastructure.

No spam. Just practical notes you can use at work.

Sachin Sarawgi

Written by

Sachin Sarawgi

Engineering Manager and backend engineer with 10+ years building distributed systems across fintech, enterprise SaaS, and startups. CodeSprintPro is where I write practical guides on system design, Java, Kafka, databases, AI infrastructure, and production reliability.

Found this useful? Share it: