Free preview

Cheat Sheet

Key takeaway

A CDN solves distance, not repetition. Edge servers near users cut propagation delay, stop the origin sending identical bytes once per user, and remove the single point of failure — which is why it's an architecture, not an optimization.

Key terms

TermOne line
Edge server / proxyCaching server at the network edge, near users
PoPPoint of presence — a location holding numerous proxy servers
Origin serverSource of truth; serves what the CDN doesn't have
Routing systemDecides which edge serves a given client
Distribution systemMoves content from origin out to the edges
Scrubber serversFilter malicious traffic (DDoS) before it reaches proxies
IXPInternet exchange point — where networks interconnect
TTRTime-to-refresh — polling interval in the pull model
ESIEdge Side Includes — markup marking which page parts are dynamic
OCANetflix's Open Connect Appliance

Cache ≠ CDN. A cache reduces repeated work; a CDN reduces distance.

Why a CDN is mandatory at scale

Latency     US East -> US West    = 62.9 ms
            US East -> Cape Town  = 225.63 ms      (VoIP budget is 150 ms)

Bandwidth   Origin must send the same bytes once PER USER
            250k req/sec * 500 KB * 8 = 1 Tbps sustained from one origin

Failure     One data center = one single point of failure

Components

ComponentJob
ClientsRequest content
Routing systemDirect clients to the optimal facility (placement, volume, load, URI namespace)
ScrubbersSeparate legitimate from malicious traffic
Proxy serversServe content — hot in RAM, cold on SSD/disk
Distribution systemPush content from origin to edges
Origin serversSource of truth + mapping metadata
Management systemLatency, downtime, packet loss, load, billing

Key detail: distribution feeds cache state back to routing, so routing picks an edge on availability, not just proximity.

Functional ops: retrieve · request · deliver · search · update · delete Non-functional: performance · availability (incl. DDoS) · scalability · reliability + security Building blocks reused: DNS (routing) · load balancers (intra-PoP distribution)

Push vs pull

Push CDNPull CDN
Initiated byOrigin serverFirst user request
Managed byContent providerThe CDN
ReplicasMore — better availabilityFewer
StorageHigherLower
First-request latencyFastSlow (origin round trip)
Changing contentPoor — redundant pushesGood
Best forStatic assets, predictable demandDynamic content, large catalogues

Most providers use a hybrid. Push the stable and universally-needed; pull the long tail. Pull's weakness: cold start — first user per region pays origin latency. Fix with cache warming + tiering.

Dynamic content

TechniqueWhat it does
Edge scriptingRun scripts at the proxy using location, time, third-party APIs
Compressione.g. Cloudflare Railgun — shrinks the origin-to-proxy leg
ESICache the static shell, fetch only dynamic fragments; not a W3C standard but widely used
DASH / HLSManifest of URIs per resolution; each resolution is a cacheable static object

Rule: compute at the edge when inputs are the request itself. Keep it at origin when inputs are shared mutable state.

Multi-tier hierarchy

Origin -> Parent proxies -> Edge proxies -> Clients
(typically one or two tiers)

The arithmetic: 1,000 edges miss the same object → 1,000 origin requests flat, or 20 with a parent tier = 50x reduction.

Long tail: few items get most requests; a long tail gets few each. → Head in edge RAM, tail on parent disk. Multi-layer cache handles the tail.

Failures: child fails → DNS routes elsewhere · parent fails → child knows many parents · origin fails → hot backups + replicated store.

Request routing

"Nearest" = network distance (path length + bandwidth) + request load — NOT geography.

MechanismWho decidesConvergesWeakness
DNS redirectionCDN authoritative DNSMinutes (TTL)Slow failover; resolver caching skews load; resolver ≠ user location
AnycastThe network (BGP)FastLess precise load control
HTTP redirectionOrigin (302 + Location)ImmediateCosts a full origin round trip first
Client multiplexingThe clientImmediateClient lacks load/health info — picks badly

DNS redirection has two steps: map client → location, then load-balance within the PoP. Short TTLs at step 2 allow shifting clients. Used by Akamai.

Consistency

MechanismDirectionStalenessCost
Periodic polling (TTR)Proxy asks on a scheduleUp to one TTRWasted bandwidth when content rarely changes
TTLProxy revalidates on expiry, when requestedUp to the TTLOne revalidation per expiry, only for requested objects
LeasesOrigin notifies the proxyNear zeroOrigin must track outstanding leases; adaptive leasing tunes duration

TTL bounds staleness — it does not deliver freshness. Takedowns and mispricing need explicit purge. Stampede risk: identical TTLs synchronize revalidation. Use jittered TTLs + request coalescing.

Deployment

StrategyWhereSuits
On-premisesSmall data centers near IXPsVolatile or vast catalogues (Google)
Off-premisesInside ISP networks — one hop from usersLarge but stable catalogues (Akamai, Netflix)

Split TCP: terminate client connections at a nearby edge (cheap handshake, fast ramp), forward over persistent, large-window connections to origin — helps even for uncached content. Predictive push: proactively move content closer based on forecast demand. Tools: ProxyTeller (hit ratio, bandwidth, latency); greedy / random / hotspot algorithms.

Why ISPs accept the box: cuts their external bandwidth bill · improves customer responsiveness · reduces internet-core traffic.

Build vs buy

Public CDN risks: outages outside your control · coverage gaps · blocking from shared domains/IPs due to other customers' content.

Netflix Open Connect — OCAs store no user data; they report health/routes/available files to a control plane in AWS and serve content directly. Why they built it: scalability · cost · security · control · diagnostics · retention. Hit ratio ~95%.

Build only when: your volume distorts provider pricing and the catalogue supports a high hit ratio. Otherwise buy. Even when building, keep a public CDN for overflow and failure.

Quick decision cues

  • Global users + one origin → CDN is mandatory, not optional
  • Stable, universally-needed assets → push
  • Large or fast-changing catalogue → pull
  • Mostly-static page with a personalized strip → ESI
  • Response depends only on the request → edge scripting
  • Needs authoritative shared state → keep at origin
  • Thousands of edges, one origin → add a parent tier
  • Need fast failover → anycast, not DNS
  • Must disappear immediately → purge, not TTL
  • Stable catalogue, latency critical → place inside ISPs
  • Not Netflix-scale → buy

Work the Interview Walkthrough for the full design and the Concept Drills for rapid-fire practice.

Enjoying the preview?

Create a free account to unlock the rest of this course, the in-browser judge, and live AI mock interviews.

Sign up free to continue