Skip to content
Optimal Lab

System design · interactive

CDNs: caching at the edge

Your origin server is in Virginia. Users in Karachi, London and New York each load your logo once per tick. Put a CDN in front, choose how long edges may keep a copy, then ship a new logo and see who still gets the old one.

Karachi edge

MISS · 252 ms · v1 until t10

London edge

MISS · 95 ms · v1 until t10

New York edge

MISS · 23 ms · v1 until t10

Origin (Virginia)

logo v1 · 3 requests

012345▼78910111213
KarachiMHHHHHHHHHMHHH
LondonMHHHHHHHHHMHHH
New YorkMHHHHHHHHHMHHH

H hit · M miss (went to origin) · red = old logo after the deploy · ▼ new logo ships

Tick 0: 3 edges had to go to the origin.

Cache-Control max-age (TTL)

When the new logo ships (tick 6)

Do nothing. Each edge refetches when its copy expires.

hit ratio
0%
origin requests
3
stale logos
0
tick 0 of 13
  1. 1

  2. 2

  3. 3

    The edge fetches from Virginia, stores the copy for max-age, and returns it. Far-away users pay the full round trip.

    Karachi +240 ms · London +85 ms · New York +15 ms

  4. 4

  5. 5