CDNs in system design interviews

A content delivery network (CDN) is a fleet of cache servers placed in many locations close to users, which serve copies of your content so most requests never reach your own servers. In a system design interview, a CDN is the standard answer for static files, images, video and audio segments; the questions that earn credit are what is cacheable, how long it stays fresh, how you change it, and what happens on a miss.

By Published 7 min read

1. What a CDN is

Your application runs in a few regions; your users are everywhere. Each round trip across an ocean costs tens to hundreds of milliseconds, and serving every image and video byte from your own data centers costs bandwidth and servers. A CDN places caching proxies in many cities. A user's request goes to the nearest one, which returns a stored copy if it has one and otherwise fetches it from your origin (an object store or your web servers), stores it, and returns it. Commercial CDNs also terminate TLS, absorb attacks and run small amounts of code at the edge, but caching is the core idea.

2. Why interviewers ask about it

Any design that serves media or a global audience needs a CDN, and saying "put it on a CDN" without detail is one of the most common hand-waves in system design rounds. Interviewers follow up with: what exactly is cached, what is the TTL, how do you update a file that changed, how do you protect paid content, and what happens to the origin when a new release is requested by millions at once.

3. How a user reaches the right edge

Two ways to steer users to a point of presence
MethodHow it worksStrengthWeakness
DNS-based steeringThe CDN's DNS server answers the hostname with the address of a PoP chosen for the resolver's location and the PoP's loadFine control per request; can avoid overloaded or failed PoPsDecides by the resolver's location, not the user's; DNS caching delays changes
AnycastMany PoPs announce the same IP address; internet routing delivers packets to the nearest one in network termsSimple, fast failover when a PoP withdraws its route; strong against DDoS because attack traffic spreads outLess precise load control; a routing change mid-connection can move a long TCP session
Two ways to steer users to a point of presence. Scroll sideways on a small screen.

Many CDNs combine the two. In an interview, one sentence is enough: "Users reach the nearest PoP through anycast or geo-aware DNS, and failed PoPs drop out of rotation."

4. Cache tiers and the origin shield

  1. Users
    • Browsers, apps, players
  2. Edge PoPs
    • Load balancer hashing by URL
    • Edge cache servers (memory + SSD)
  3. Mid tier
    • Regional shield cache
    • Request collapsing
  4. Origin
    • Object storage
    • Application servers for dynamic content
Request path through a tiered CDN. A user's request goes to the nearest edge PoP. Inside the PoP, a load balancer hashes the URL so each object lives on one or a few cache servers. On a miss, the edge asks a regional shield cache instead of the origin. The shield collapses concurrent misses for the same object into one request to the origin, which is an object store or an application server. Responses flow back and are stored at the shield and the edge according to their cache headers.
  • Within a PoP, consistent hashing on the URL sends each object to the same server, so the PoP's total disk acts as one large cache instead of many copies of the same popular files.
  • The shield sits between edges and origin. Without it, a new file requested in 100 PoPs could cause up to 100 origin fetches; with one shield per region, it causes a handful.
  • Request collapsing means that if 5,000 users ask an edge for the same uncached object in the same second, the edge sends one request upstream and the rest wait for it.
  • Tiered storage at each edge keeps the hottest objects in memory, the warm set on SSD, and evicts the long tail first.
edge egress at peak:      1,000 Gbps (1 Tbps)
hit ratio 95%:            origin serves 5%  = 50 Gbps
hit ratio 99%:            origin serves 1%  = 10 Gbps
effect:                   four points of hit ratio cut origin load five-fold
with a shield at 90% hit: origin sees 10% of edge misses: 5 Gbps or 1 Gbps
Why hit ratio matters (assumed figures)

This arithmetic is the most useful thing to say about a CDN in an interview. It explains why you add a shield, why long TTLs matter, and why a launch that empties caches is dangerous for the origin.

5. Cache keys, freshness and changing content

The cache key is usually the host plus the path plus some query parameters. Strip parameters that do not change the response (tracking tags), or every variation becomes a separate miss. Freshness is set by the origin's response headers.

Cache-Control directives worth knowing
DirectiveMeaningTypical use
max-age=NBrowsers and CDNs may reuse the response for N secondsStatic assets, often with a long N
s-maxage=NOverrides max-age for shared caches such as the CDN onlyLet the CDN keep an API response briefly while browsers revalidate
stale-while-revalidate=NServe the stale copy for up to N seconds while fetching a fresh one in the backgroundPopular pages where a few seconds of staleness is fine
privateOnly the user's browser may cache it, never a shared cachePersonalized pages and account data
no-storeDo not cache anywhereSensitive responses
immutableThe content at this URL will never changeVersioned file names such as app.3f9c1a.js
Cache-Control directives worth knowing. Scroll sideways on a small screen.
  • Versioned URLs (preferred). Put a content hash or version in the file name. A deploy publishes new names and updates the HTML that references them; old files simply age out. No purge is needed, and there is never a mix of old and new.
  • Purge (invalidation). Ask the CDN to drop a path or a tag from every PoP. Useful for mistakes and legal takedowns, but it takes time to reach every edge, and a broad purge sends a wave of misses to the origin.
  • Short TTLs. Fine for content that changes often, at the cost of a lower hit ratio and more origin traffic.

6. Beyond static files

  • Video and audio. Media is cut into segments of a few seconds at several bitrates, each one an ordinary cacheable file. The music streaming walk-through and the Netflix walk-through show this at scale; some providers also pre-position popular titles on edge servers before peak hours.
  • Large downloads. Range requests let a client fetch part of a file, and edges cache ranges or whole objects depending on configuration.
  • Dynamic APIs. Even uncacheable responses gain from a CDN: TLS is terminated near the user, and the edge keeps warm, reused connections to the origin, which cuts handshake time.
  • Protected content. Signed URLs or signed cookies carry an expiry and a signature the edge can check without calling your servers, so only paying users fetch premium files.
  • Security. Edges absorb volumetric DDoS traffic and can run a web application firewall before requests reach you.
  • Live calls are different. Real-time video calls need delays under a second and go through media servers, not a CDN; only a broadcast version with several seconds of delay fits the CDN model. See the video conferencing walk-through.

7. How CDNs show up in common prompts

The CDN question in each walk-through
PromptWhat the CDN servesThe interesting part
Music streamingAudio chunks at several bitratesLong-tail catalog: edges hold hits, shields hold the middle
NetflixVideo segmentsPre-filling edges before peak viewing hours
URL shortenerOptionally the redirects themselvesA cached 301 cuts load but hides clicks from analytics
E-commerce checkoutProduct pages and imagesKeeps sale-day browsing away from checkout services
API gatewayThe edge in front of the gatewayTLS and DDoS absorption before traffic reaches the gateway fleet
CachingOne layer among severalHow CDN freshness fits with app and database caches
The CDN question in each walk-through. Scroll sideways on a small screen.

8. Mistakes to avoid

  • Caching personalized responses in a shared cache. A missing private or a cache key without the user can show one person's page to another.
  • Relying on purges for every deploy. Versioned file names are faster and safer.
  • Ignoring cold launches. A new release that every user requests at once is all misses; pre-warm the shield and edges, or stagger the rollout.
  • Letting query strings fragment the cache. Normalize or ignore parameters that do not affect the response.
  • Treating the CDN as storage. The origin remains the source of truth; edges evict whatever they want.
  • Forgetting cost and logs. Egress is billed, and edge logs are how you count downloads or plays, so ship them somewhere useful.

9. How to talk about it in the interview

  • Say which objects go on the CDN and which never do (personalized or sensitive responses).
  • Give the TTL strategy in one sentence: long TTLs with versioned names, short TTLs or purge only where needed.
  • Use hit-ratio arithmetic to size the origin.
  • Mention the shield and request collapsing when a launch or viral object comes up.

Fictional example

Handling a launch-day miss storm
Interviewer
A new game update of several gigabytes goes live at 9 a.m. for millions of players. What happens to your origin?
Candidate
Without preparation every edge misses at once. I would push the files to the regional shields before 9, so edges fill from shields instead of the origin, and keep request collapsing on so each edge fetches each chunk once. The files have versioned names with long TTLs.
Interviewer
And if the origin still struggles?
Candidate
Stagger the rollout by region or by percentage of players, which spreads the misses over an hour. The client retries with backoff, and the origin only ever sees shield traffic.

Practicing with Natively

Interviewers ask CDN follow-ups inside almost every design, so practice answering them in two or three sentences. Run a mock call with a friend and keep Natively open on your laptop: it writes down the conversation as it happens and, when you ask, offers points for the question on the table, for example the shield or versioned file names. You can also ask it to draw the tiered request path and check it against your own picture. The transcript you keep makes it easy to see which answers ran long.

Questions people ask

What is a CDN in system design?

A content delivery network is a set of cache servers in many locations close to users. A request goes to the nearest point of presence, which returns a stored copy or fetches it once from your origin and keeps it, so most traffic for static files and media never reaches your own servers.

What is an origin shield in a CDN?

It is a mid-tier cache between the edge locations and your origin. Edges that miss ask the shield instead of the origin, and the shield collapses simultaneous requests for the same object into one origin fetch, so a new or expired file causes a handful of origin requests instead of one per edge.

How do you update a file that is cached on a CDN?

The safest way is to give each version a new file name, usually with a content hash, and update the page that references it; the new URL is fresh everywhere at once and old copies age out. Purging a path from every edge works for urgent fixes but takes time to spread and sends a burst of misses to the origin.

Can a CDN help with dynamic API responses?

Yes, even when the response cannot be cached. The edge terminates TLS close to the user and reuses warm connections to the origin, which cuts connection setup time, and it filters attack traffic. Short shared-cache lifetimes, set with s-maxage, also let it cache some public API responses for a few seconds.

Where to go next

Practice with the same assistant you would use on a call: it listens, transcribes and suggests answers from your own resume and the job description.

Facts on this page were last checked on . Product details come from the Natively app itself; if something here is out of date, tell us at hello@heynatively.com.

Keep reading

Put it on your own machine.

A live-conversation assistant that runs locally. Your conversations stay on your machine.

macOS 12+ · Windows 10/11

© 2026 Natively AI Private Limited

Source-available under the Natively Personal Use Source License v1.0 · IP geolocation by DB-IP