← Lessons

quiz vs the machine

Silver1050

System Design

How a CDN Works

A content delivery network moves copies of your content closer to users.

4 min read · intro · beat Silver to climb

The Core Idea

A content delivery network is a fleet of servers spread across many cities. Instead of every request travelling to one distant origin, the user connects to a nearby edge node. Shorter distance means lower latency and less load on your servers.

What Lives at the Edge

  • Cached responses such as images, scripts, and video segments
  • A map of which edge is closest to each user, usually resolved through DNS
  • Connection termination so the slow first handshake happens nearby

When an edge has the file, it serves a cache hit in milliseconds. When it does not, it fetches from origin, stores a copy, then replies. The next user in that region gets a hit.

Why It Matters

  • Faster page loads because bytes travel a shorter path
  • Lower origin cost since most traffic is absorbed at the edge
  • Better resilience because one origin outage does not take down every region

Key idea

A CDN spreads cached copies across many edge locations so users connect to a nearby node, cutting latency and shielding the origin from most traffic.

Check yourself

Answer to earn rating on the learn ladder.

1. What is the main benefit of serving content from a nearby edge node?

2. What happens on a cache miss at the edge?