Interview's MateSystem Design
Interview's Mate

System Design

Architecture & trade-offs

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
System Design topics
Lesson 5/ 31
Fundamentals & Networking

CDN & Edge Computing

Serve static media, video segments, and dynamic edge logic milliseconds from the user.

BeginnerEdge PoPs · Origin Shield3 quiz questions0/2 subtopics done
Practice in AI HLD
In plain wordsDiagramTheorySubtopics (2)Step by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice
Deep-dive subtopics (2) - 0/2 completed
Push vs. Pull CDNs & Origin Shield

Fetch on demand (Pull), pre-warm ahead of spikes (Push), and protect origin with an Origin Shield.

Beginner
Edge Computing & Cache-Control

Run lightweight logic near users and control freshness with HTTP caching headers.

Intermediate

In plain words

A CDN keeps copies of your files (images, videos, scripts) on servers all over the world, so users download them from somewhere close instead of from your one main server.

Think of it like…

Local neighborhood convenience stores stocked from one central warehouse so shoppers do not drive 500 miles for milk.

Where you’ve seen it

A YouTube video is cached on a server in your city. When you press play it loads quickly, and the main data center never sees your request.

Words you’ll hear

CDN
Content delivery network: a worldwide set of servers that cache your content.
Edge / PoP
A point of presence: a CDN server location near users.
Origin
Your own main server, where the original files live.
Cache hit ratio
The share of requests served from the CDN without going to the origin.

Visual diagram

Loading interactive diagram
Loading interactive exercise

Theory & deep dive

How a CDN speeds up the web and protects your servers

A Content Delivery Network (CDN) places hundreds of edge servers (Points of Presence, or PoPs) in cities worldwide. Instead of 10 million users downloading a 5 MB video from one origin server in Virginia, they download it from a PoP a few miles from their home.

This gives two huge wins at once: lower latency for users (~15 ms instead of ~150 ms) and 90–99% lower origin load and bandwidth bills.

Key takeaway: CDNs turn global distance problems into local cache hits.

Pull CDN vs. Push CDN & Cache Invalidation

In a Pull CDN, the edge fetches files from your origin the first time a user requests them and caches them based on Cache-Control: max-age=86400. This is effortless and standard for most websites.

In a Push CDN, you upload files straight to the CDN ahead of time - useful for massive software releases or scheduled video drops. To update cached files early without slow global purges, use versioned URLs like /app.a8f3c1.js with max-age=31536000, immutable.

How it works, step by step

Step 1 of 4
CDN Edge PoP

1. User requests asset from nearest Edge PoP

Anycast or GeoDNS lands the user on an edge server <20 ms away. TLS terminates locally at the PoP.

Edge hit = ~10–25 ms total response
Key numbers at this step
Edge Cache Hit
85–98%
TLS RTT
Local PoP

When to use it & trade-offs

What it is

A Content Delivery Network (CDN) is a globally distributed network of edge servers (PoPs) that cache and serve content near users, shielding origin servers from repetitive bandwidth.

Why it matters: Fetching 5 MB images or 4K video chunks across continents burns origin bandwidth and adds 150+ ms of RTT; CDNs absorb 90%+ of that traffic at the edge.

When to reach for it

  • Images, HLS/DASH video chunks, fonts, JS/CSS bundles, and public downloads
  • Absorbing viral traffic spikes and DDoS volumetric attacks
  • Caching public API responses with Vary and stale-while-revalidate

When to avoid or be careful

  • Caching private user-specific responses on a shared URL without auth/Vary separation
  • Triggering expensive wildcard purges on every deploy instead of hashed asset filenames

Push CDN vs. Pull CDN

Pull CDN (Origin-Pull)
Best for: Most web apps, user-generated images, JS/CSS bundles

Strengths: Zero upload orchestration; edge fetches on first miss and caches by HTTP headers.

Watch out: First request per PoP incurs a cache-miss round trip to origin.

Push CDN
Best for: Large immutable media catalogs, pre-warmed software releases

Strengths: Zero cold-start misses; full control over what stays on edge disks.

Watch out: Higher storage cost and manual upload/deletion pipelines.

Edge Compute (Workers)
Best for: JWT verification, geo-redirects, A/B testing, personalization

Strengths: Runs near user before hitting origin; avoids origin round trips for simple logic.

Watch out: Tight CPU/memory limits and no direct connection to central SQL databases.

Interview signals & numbers to know

When this topic comes up

  • video streaming
  • photo sharing
  • global users
  • static assets
  • reduce egress cost

Benchmarks & rules of thumb

Edge PoP RTT -
10–30 ms
Origin Shield hit boost -
5–20× fewer origin misses
Global cache purge time -
~1–5 seconds
Bandwidth savings -
70–95% off origin

Common mistakes & follow-ups

Common interview mistakes

  • Caching authenticated responses without Cache-Control: private (leaking user A’s data to user B)
  • Skipping Origin Shield when 100+ PoPs miss simultaneously on a newly published viral video
  • Setting Vary: User-Agent or Vary: Cookie on static assets, destroying the cache hit ratio

Likely interviewer follow-ups

  • How does an Origin Shield prevent a thundering herd on your S3/origin tier?
  • When would you use content-hashed URLs vs. an active CDN purge API?
  • How do you serve private paid media (e.g., course videos) through a public CDN?
Interview tip: For private media behind a CDN, mention short-lived signed URLs or signed cookies validated right at the CDN edge.

Knowledge check

Loading quiz

Put it into practice

Design full architectures with AI feedback

Apply CDN & Edge Computing inside real High-Level Design prompts or review Q&A flashcards.

Open AI HLD Practice →SD Interview Q&A
Previous topic
Load Balancing & Proxies
Next topic
Consistent Hashing