"Design Netflix" and "Design YouTube" sound alike and are different questions. YouTube is about taking in millions of unpredictable uploads. A subscription streaming service has a small, known catalog, a very large and very predictable audience, and one overriding goal: when someone presses play, the picture starts fast and never freezes.
That changes what the interviewer is listening for. The upload and transcoding story is a background process here, covered in Design YouTube. The real subject is playback: how a player picks a quality from moment to moment, how the bytes get close to the viewer before they are asked for, and how a control plane steers each viewer to a healthy cache.
The foundation is the CDN lesson. This page assumes you know what an edge cache and a cache key are, and spends its time on the parts that are specific to long-form video.
Clarify the requirements
Functional requirements:
- Browse a catalog and search for titles.
- Press play on a title and watch it on phones, laptops, televisions and game consoles.
- Resume where you left off, on any device.
- Multiple audio languages and subtitles.
- Personalized rows on the home page (treat as a follow-up, see Design a Recommendation System).
Out of scope, said aloud: signup and billing, downloads for offline viewing, live events, DRM details beyond naming that it exists, studio content ingest.
Non-functional requirements: these decide the architecture.
- Start in about two seconds and rebuffer rarely. Both are measured, and both drive churn.
- Quality adapts to the network without the viewer doing anything, and never oscillates annoyingly.
- The origin must be nearly idle. Serving the library to tens of millions of streams from a central location is impossible, so almost every byte comes from an edge.
- Evening peak is the design point. Demand is concentrated in a few hours, and in the same hours for entire regions.
- Availability of playback matters more than freshness of the catalog. A stale row on the home page is acceptable. A stream that fails to start is not.
Estimate the scale
Assume 100 million daily active viewers out of a larger subscriber base. Assume a catalog of 20,000 titles.
Play starts: each viewer starts about 3 playbacks a day: 100M × 3 = 300 million, or about 3,500 per second, perhaps 10,000 per second at peak. That is the control plane and it is small.
Concurrent streams: at the evening peak assume 40 million streams at once. At an average of 4 Mbps, that is 40M × 4 Mbps = 160 Tbps of video leaving the edge network.
Segment requests: video is fetched in segments of about 4 seconds, so each stream requests one every 4 s. 40M ÷ 4 = 10 million segment requests per second. The playback API never sees them. The CDN does.
Catalog size: a title is encoded into a ladder of about ten video qualities plus audio tracks and subtitles. Roughly 30 GB per two-hour title for the whole ladder gives 20,000 × 30 GB = 600 TB for the entire catalog.
Progress writes: each playing client reports its position about once a minute, and a viewer watches about two hours: 100M × 120 = 12 billion updates a day, or about 139,000 per second. We only keep the latest position per profile and title, so the stored data is small even though the write rate is not.
"The control plane is a few thousand requests a second, which is easy. The data plane is 160 Tbps and 10 million segment requests a second, which no origin can serve. But the whole catalog is only 600 TB, which is small enough to place a copy of the popular part in every ISP. The design is about moving bytes to the edge before they are needed."
You can reproduce the heartbeat write rate in the capacity estimator, where the stored volume is the raw event log you would not keep.
API and data model
The control plane is a normal HTTPS API. The data plane is plain segment fetches.
POST /v1/playback/start { titleId, profileId, device, capabilities }
-> { manifestUrl, edgeUrls[], license, startPositionMs }
GET <edgeUrl>/<title>/<profile>/<segment>.m4s (data plane, from an edge)
POST /v1/playback/progress { sessionId, positionMs }
GET /v1/catalog/rows?profileId=...titles (title_id PK, metadata, available_regions)
renditions (title_id PK, profile CK, bitrate, resolution, codec, segment_index)
position (profile_id PK, title_id CK, position_ms, updated_at)
edge_state (edge_id PK, title_id CK, profiles present, health)The non-obvious choice: playback/start returns a ranked list of edge URLs, not one. The control plane picks the best edges for this viewer from health and location, and the player can switch to the next on failure without calling home.
High-level design
We simulate the data path for playback: viewers fetch from edge caches, which fall back to an origin service that reads from object storage and consults a catalog. The question to explore is how much traffic the edge absorbs.
- Viewers request segments from the CDN edge, which serves them from cache whenever it can.
- On a miss the edge asks the origin service, which reads video from S3 and metadata from the catalog.
Describe this diagram
Components
- viewers (Client)
- edge caches (Content delivery network)
- origin service (Service)
- video library (Object storage (S3))
- catalog (DynamoDB)
Connections
- viewers sends to edge caches
- edge caches sends to origin service
- origin service sends to video library
- origin service sends to catalog
Run it, then try shrinking the edge cache or turning off the origin shield. Watch how a small drop in hit rate multiplies origin load.
The start path: the player calls playback/start, which checks entitlement, picks edges, issues a license, and returns a manifest. The player starts fetching segments from the first edge URL.
The write path: progress updates stream into a key-value store keyed by profile, overwriting one row per title.
The interesting problem: adaptive bitrate
The player must choose, for every four-second segment, which quality to fetch next. Choose too high and the buffer drains and playback stalls. Choose too low and the picture is soft for no reason. This decision happens in the client, thousands of times per viewing, with only partial knowledge of the network.
Approach A: throughput-based
Measure the download speed of the last segment or two and pick the highest quality below that.
Good: simple, reacts quickly to a faster network.
Bad: throughput measured over short bursts is noisy. A single slow segment drops quality, a single fast one raises it, and the picture flaps between qualities. Estimates are also biased when segments are small and the connection has not warmed up.
Approach B: buffer-based
Ignore throughput and look at the buffer: seconds of video already downloaded and not yet played. Map buffer level to quality. Below a small "reservoir" of, say, 10 seconds, always take the lowest quality to protect against a stall. Above an upper threshold, take the highest. In between, choose a quality rising smoothly with the buffer.
Good: directly aimed at the thing the viewer cares about, which is avoiding stalls. It is stable, because buffer changes slowly.
Bad: at the start of playback the buffer is empty, so it begins at low quality and ramps slowly. It also reacts late to a sudden drop in bandwidth.
Approach C: hybrid
Use throughput to choose the starting quality and the early ramp, then hand control to the buffer-based rule once the buffer has built up, with throughput as a safeguard: never request a quality whose segment cannot download in less than its playing time.
The recommended design is C. On the server side, you help the player by shipping a ladder suited to each title: a cartoon with flat colors reaches good quality at a far lower bitrate than a film with grain, so a per-title ladder saves bandwidth without losing quality. Segments are aligned across qualities so the player can switch at any boundary.
The second decision: putting bytes next to the viewer
At 160 Tbps, even a good CDN hit rate leaves a flood at the origin: a 1% miss rate on 10 million requests a second is 100,000 origin requests a second. The aim is hit rates above 99%, with the remaining misses going to a nearby parent cache, not to the library.
Cache inside the ISP. Place edge appliances in or beside ISP networks, so streams do not cross the internet at all. Each holds the part of the catalog its audience actually watches. The popular head is tiny: the top 200 titles at 30 GB each is 6 TB, small enough to sit on one appliance.
Fill proactively, not on demand. Popularity of a catalog is predictable from release schedules and viewing history. Push the expected popular titles to edges overnight, during the off-peak, so the peak is served almost entirely from disk. Reactive fill (cache on first miss) handles the long tail and surprises.
Steer with the control plane. playback/start ranks edges by proximity, current load, health and whether the title is present, and returns several. A failing edge is demoted for everyone within seconds.
Bottlenecks and failures
A premiere night. A new season drops and millions press play on the same title at midnight. Pre-position it to every edge before release, since you know the date, and cap the first-hour bitrate if the network is stressed. Without pre-positioning, the origin sees a thundering herd of misses on the same segments, which an origin shield collapses into one fetch each.
An edge server fails. The player has a ranked list and switches to the next URL on the next segment. The buffer of 20 to 30 seconds hides the switch.
An ISP link is saturated. The control plane steers new sessions to another edge, and players step down a rung on their own, so quality dips and nobody stalls.
The playback API is down. Streams already playing continue, because segment fetches do not use it. Only new starts fail. Cache entitlement decisions briefly and let a client that was authorized a minute ago resume.
Stale catalog or recommendations. Serve the last known good rows. Availability beats freshness for the home page.
Trade-offs to name aloud
- Edge appliances inside ISPs: very high hit rates and low transit cost, in exchange for operating hardware you do not own the rooms for.
- Proactive overnight fill: a predictable peak, at the cost of a prediction that can be wrong for surprise hits.
- Player-side adaptation: the server stays simple and cacheable, but behavior depends on client implementations across thousands of devices.
What interviewers listen for
- A working answer: a CDN in front of object storage, a manifest of several qualities and a player that switches quality with bandwidth.
- A strong answer: separates the small control plane from the enormous data plane, sizes the 10 million segment requests per second, explains buffer-based or hybrid adaptation, and fills edges proactively off-peak.
- A standout answer: also notes the whole catalog is small enough to replicate popular titles into every ISP, steers with ranked edge lists, pre-positions releases, and states that already-playing streams survive a control plane outage.
Check your understanding
Common mistakes
Describing it as YouTube with a different logo. The audience, catalog and bottleneck differ. A fixed catalog is small enough to pre-position, which changes everything about caching.
Putting the playback API on the segment path. If every four-second segment passes through an API, you have built a 10 million request per second bottleneck. Segments are static files.
Relying on cache-on-miss only. A cold edge at the evening peak creates exactly the origin load you are trying to avoid. Fill popular content ahead of demand.
Ignoring failure of the control plane. "What if playback start is down?" has a good answer: running streams continue, because segments never touch it.
Practice
Your CDN hit rate at the evening peak drops from 99.5% to 98.5% after a catalog update. Estimate what happens at the origin, and how you would investigate.
Write your own answer first, on paper or in a note. Then compare.
Show a hint
Convert hit rate into origin requests per second, and think about what a catalog update changes about the cache.
Show a strong answer
Do the arithmetic. At 10 million requests a second, a 0.5% miss rate is 50,000 origin requests a second, and 1.5% is 150,000. A one-point drop in hit rate triples origin load. This is why hit rate is the headline metric.
Look for a cache-key change. If the update changed segment paths, codecs or manifest versions, edges hold old objects under old keys, and every request looks new. Compare the keys of requests that miss with those of the objects on disk.
Mitigate now. Raise the origin shield's role so concurrent misses collapse, serve old encodings until new ones are filled, and temporarily lower the top rung's bitrate to reduce bytes.
The pattern worth keeping: express cache health in origin requests per second, and when it moves suddenly, suspect a cache-key change before capacity.
A viewer on a congested home network complains that the picture keeps jumping between sharp and blurry. What is likely wrong, and how do you fix it in the player?
Write your own answer first, on paper or in a note. Then compare.
Show a hint
Recall which signal a throughput-only rule reacts to, and what you would add to damp it.
Show a strong answer
Oscillation from a throughput rule. On a congested link, segment download speeds vary a lot from one request to the next. A rule that picks the quality from the last measurement moves up and down with the noise.
Add hysteresis. Switch up only when the estimate has been comfortably above the next rung for several segments, and switch down immediately when the buffer is draining. Quick to protect, slow to improve.
Smooth the estimate. Use a moving average or a low percentile of recent throughput, not the latest sample.
Let the buffer lead. Once the buffer is above the reservoir, choose the quality from buffer level, which changes slowly, and use the throughput estimate only as a ceiling.
The pattern worth keeping: control loops over noisy measurements need smoothing and asymmetric thresholds, down fast and up slow.
Key takeaways
- Two planes: a small control plane (thousands of requests a second) and an enormous data plane (160 Tbps, 10 million segment requests a second).
- The catalog is small enough to replicate. Put the popular part next to every audience.
- The player chooses quality. A hybrid of throughput and buffer rules is stable and responsive.
- Fill edges before demand, use an origin shield for what remains, and pre-position known releases.
- Return several edges, so a failed server costs one segment, not a stall.
- Running streams survive a control plane outage. Say so.
Further reading
- T.-Y. Huang et al., "A Buffer-Based Approach to Rate Adaptation: Evidence from a Large Video Streaming Service", ACM SIGCOMM (2014): the buffer-based rule and its reservoir.
- R. Pantos and W. May, RFC 8216 "HTTP Live Streaming" (2017): manifests and segments as plain cacheable files.
- ISO/IEC 23009-1, "Dynamic adaptive streaming over HTTP (DASH)": the standard manifest format for adaptive streaming.