System Design: Netflix (Walnut Flix: Encoding, ISP Caches, Nightly Fill, Playback, Stream Limits, Bookmarks, Live Events)
We design a video streaming service, like Netflix, and call it Walnut Flix. Studios send us finished films and series. Members watch them on TVs, phones and laptops, and pick up where they stopped on any device.
Netflix shows a fixed catalog. Nobody uploads videos, so we know every file long before anyone presses play. So we can copy every file to boxes inside internet providers days before a release.
As in any system design interview, the numbers are assumptions for planning. Every number here is our own assumption, and the design is our own.
All times are in November 2026. They are in US Mountain Time, Denver's time, unless a line says otherwise. Boston is two hours ahead of Denver, and Las Vegas one hour behind.
How to read this post. It takes about 90 minutes in full, so it is built to be read in parts:
1. Requirements
1.1 What we are building
Walnut Flix does three jobs:
- Prepare each title. Turn a studio's huge master file into small files that every TV, phone and browser can play. Lock them so only our players can show them.
- Deliver the bytes. Place the files inside the viewers' internet providers before anyone asks. Then start each play in under a second and keep it smooth.
- Know the member. Limit streams to the plan, and remember where each person stopped on every device. Stream live games to tens of millions at once.
The story, one week in November:
- Tue 3 Nov, 11:00. A studio delivers season 2 of The Quiet Line: 8 episodes of 55 minutes. The season goes live worldwide in 10 days.
- Wed 4 Nov, 07:00. The season is encoded, locked and ready to copy.
- Mon 9 to Wed 11 Nov, nights. Cache boxes inside internet providers copy the season while viewers sleep. By Thursday 01:00, 99.75% of the boxes that should hold it have it.
- Fri 13 Nov, 01:00. It is midnight in Los Angeles. The season goes live in every country at the same moment.
- Fri 20:00. In Denver, Laura Bennett presses play on the living-room TV. The first picture shows 0.35 s after her tap.
- Fri 20:30. Laura's daughter Emma is 15. Emma starts the season on her phone. The family's plan allows two streams at once.
- Fri 20:58. Mike Bennett is Laura's husband and the account owner. He is in a Boston hotel. The hotel TV asks him for a travel code, then refuses a third stream.
- Sat 09:15. Emma moves to the TV and resumes episode 3 at 37:07, where her phone stopped.
- Sat 12:30. On a short flight, Emma watches a downloaded episode with no network. Her phone sends those old events at 17:10, after she has watched more on the TV.
- Sat 23:00. Victor is an attacker in Las Vegas. He tries 2 million stolen email and password pairs. Later he tries to copy a title from a laptop browser.
- Sun 15 Nov, 18:20. A live American football game starts. At 21:05, 24 million devices watch it at once.
- Sun 20:41. One of the two cache boxes at Laura's internet provider in Denver loses power during the game.
What happens to each person, by Sunday night:
- The season starts on time in every country. No box had to fetch it on release night.
- Laura's TV shows the first picture in 0.35 s on Friday. On Sunday, the failed box does not make her picture stop.
- Mike's hotel TV plays at 21:01:30, as soon as Emma stops. The plan's limit of two streams holds.
- Emma's resume point is never pulled back by the late events from her phone.
- Victor gets into about 200 accounts before the sign-in checks slow him down. His browser gets at most 720p, and his copying tool is refused after 20 licenses.
The hard part has three pieces:
- About 385 Tbit/s, trillions of bits a second, must come from boxes that were filled the night before.
- About 30,000 play starts and 1.46 million small position updates arrive each second at the design peak.
- A live game has nothing to fill ahead of time.
1.2 Words we use
Words used in only one place are explained there. Each word below is used all through the post.
Video.
| Word | Meaning here |
|---|---|
| Title | A film or a series |
| Master | The studio's finished file of one episode or film, far bigger than anything we stream. Ours average 500 Mbit/s |
| Mbit/s | Millions of bits a second. Tbit/s is a million Mbit/s |
| Codec | A method that compresses video into fewer bits. We use three: H.264, also called AVC, which every device plays; HEVC, High Efficiency Video Coding, for 4K TVs; and AV1, about a third smaller than H.264 for the same picture |
| Bitrate | The bits a second a video file uses, such as 2.5 Mbit/s |
| Rung | One version of a title: one codec, one picture size and one bitrate, such as AV1 at 1080p and 2.5 Mbit/s. 1080p means 1,080 rows of pixels; 4K, also called 2160p, means 2,160 |
| Ladder | All the rungs a title gets. Ours has 13 video rungs |
| Segment | A 4-second piece of one rung. A player fetches a video one segment at a time, and a live game uses 2-second segments |
| Manifest | A small file that lists a title's rungs and where their segments are |
| Shot | The frames between two camera cuts |
| CPU-hour | One processor core busy for one hour |
Delivery.
| Word | Meaning here |
|---|---|
| ISP | An internet provider, the company that brings the internet to a home or a phone |
| ISP box | Our cache server inside an internet provider's own building. It holds the most-watched files and sends most of the bytes |
| Exchange site | Our bigger cache site where many internet providers connect. It holds the whole catalog |
| Box | An ISP box or a server in an exchange site |
| Fill | Copying files to a box at night, before anyone asks for them |
| Steering | Telling each player which three boxes to use |
| Egress | The bytes we send to viewers |
| CDN | Content delivery network: another company's cache servers, which we can rent |
| Hop | One router that data passes through on its way |
Members.
| Word | Meaning here |
|---|---|
| Account | One paying household's subscription, with one owner |
| Profile | One person inside an account, with their own resume points and history |
| Plan | What the account pays for, such as "Standard": two streams at once, up to 1080p |
| Stream | One player fetching video right now |
| Slot | One of the plan's allowed streams. A playing device holds one |
| Lease | A hold that ends by itself at a set time unless it is renewed. A slot is a lease of 5 minutes |
| Household | The devices that watch at the account's home |
| Travel code | A one-time code, sent to the owner, that lets a TV outside the home play for 7 days |
| DRM | Digital rights management: segments are encrypted, and only a licensed player can decrypt them |
| License | A signed message with the keys to decrypt a title. It works for 10 minutes and is renewed every 2 minutes |
| Key group | A set of rungs that share one key: audio, SD, 720p, 1080p or 4K. SD, standard definition, is below 720p |
| Bookmark | The saved resume point for one profile and one title: an episode and a position |
| Heartbeat | A small message a player sends every 60 seconds while it plays, with its position |
| Continue Watching | The home screen row of titles a profile is in the middle of |
The system.
| Word | Meaning here |
|---|---|
| Region | One of our four groups of data centers in the cloud: US East, US West, Europe and Asia-Pacific |
| Zone | One building or group of buildings inside a region, with its own power |
| p95 | A time that 95 of every 100 requests meet. p50 is the time half of them meet |
| Shard | One slice of a store, holding some keys. Each shard has copies in three zones |
| Put if absent | A write that succeeds only if no row with that key exists yet, so a repeat adds nothing |
IDs in this post. Every ID below is made up.
| ID | What it names | Example from the story |
|---|---|---|
| a_3307 | An account ID | The Bennett family's account, owned by Mike |
| pf_201, pf_202, pf_203 | A profile ID | Laura, Mike and Emma |
| dv_tv1 | A device ID | The living-room TV in Denver, the family's main TV |
| dv_ph3 | A device ID | Emma's phone |
| dv_ph2 | A device ID | Mike's phone |
| dv_htl9 | A device ID | The TV in Mike's Boston hotel room |
| t_ql | A title ID | The Quiet Line, season 2 |
| ss_7Hq2, ss_9Kd4, ss_Mk55 | A session ID: one episode played, from play to stop, made by the player | Laura's play at 20:00, Emma's at 20:30, Mike's at 21:01 |
| ss_Pz81 | A session ID | Emma's offline play on the flight |
| lic_81 | An offline license ID | Emma's download of episode 4 |
| ss_7Hq2:14 | An event ID: the session ID and a counter | The 14th event of Laura's play |
1.3 Every kind of request and change
Walnut Flix handles more than the story shows. This table lists every kind. Each part it names is explained where it first appears in the design.
| Kind | What it is | How big or how often | Part that handles it | Outside company that takes part |
|---|---|---|---|---|
| Studio delivery | A studio sends the masters, audio and subtitles of a title | about 40 hours of new runtime a day | Studio portal | The studio |
| Encode | Turn one master into all its rungs | 96,000 CPU-hours a day | Encoding orchestrator, Encode fleet | none |
| Nightly fill | Copy new and popular files to every box | about 2.5 TB a box a night | Fill service, boxes | The internet provider gives rack space and power |
| Home screen | A profile opens the app | about 2 billion a day | Homepage service | none |
| Play | A press of play, from tap to first picture | about 733 million a day | Playback service, Steering service, License service | none |
| Segment fetch | A player asks a box for the next 4 seconds | about 20 million a second at the design peak | ISP boxes, exchange sites | The internet provider carries the bytes |
| License renewal | A playing device renews its keys every 2 minutes | about 668,000 a second at the design peak | License service, Slot service | none |
| Heartbeat and player events | Position every 60 seconds, plus start, pause, seek and stop | about 1.46 million a second at the design peak | Event log, Bookmark writer, History service | none |
| Travel code | A TV outside the home asks to play | a few hundred thousand a day | Household service | An email and text message provider sends the code |
| Download | A phone saves an episode to watch with no network | about 20 million a day | Download service, License service | none |
| Live event | A game streamed as it happens | a few a month, up to 24 million streams at once | Live pipelines, Live origin, boxes | The venue's video feed; rented CDNs for extra bytes |
| Sign-in | A member signs in on a new device | about 5 million a day | Account service, with its failed sign-in counts | none |
| Hide or delete | A member hides a title or deletes a profile | about 1 million a day | History service, Account service | none |
| Re-encode | Run a new encoder over old titles | a few times a year | Encoding orchestrator | none |
1.4 Functional requirements
- Prepare. Turn a studio's masters into files that every kind of device can play, and check them before anyone sees them.
- Protect. Encrypt every title. Give keys only to licensed players, and give the best quality only to the safest devices.
- Release. Make a title playable in every country at one set moment, with its files already near the viewers.
- Play. Start a play fast on any device, anywhere, and change quality as the network changes.
- Limit. Hold each plan's number of streams at once, and its household and download rules.
- Resume. Save where each profile stopped, resume there on any of its devices, and show Continue Watching.
- History. Keep each profile's viewing history, and let a member hide a title or delete a profile.
- Live. Stream a live event to tens of millions of devices at once.
- Survive failures. Keep playing through the loss of a box, a site or a region.
Out of scope:
- buying content and payments;
- search ranking and how recommendations are trained;
- ads and A/B tests.
They are other teams' services. The Homepage service asks the recommendation team for each profile's rows.
1.5 Non-functional requirements
- Start time. We measure from the tap to the first picture, on a link of 5 Mbit/s or more. The p50 is at most 1 s, and the p95 at most 2 s. For live, the p95 is at most 3 s.
- Smooth play. The picture stops to wait for data at most 0.2% of watch time. At most 0.3% of plays fail to start.
- Release. 24 hours before release, a title sits on at least 95% of the ISP boxes that should hold it. It becomes playable in every country within 1 minute of its release time.
- Bookmarks. A pause or a stop is saved within 5 seconds. While a title plays, the saved position is at most 60 seconds behind.
- Availability. 99.99% of play starts succeed in a month.
- Stream limit. A new stream is refused when the account holds all its slots. A device that dies without saying so frees its slot within 5 minutes.
- Protection. 1080p keys go only to devices that keep keys in a protected chip. A browser that keeps keys in software gets at most 720p.
- Hiding and deleting. A hidden title leaves Continue Watching on every device within 1 minute. A deleted profile's data leaves every store and backup within 30 days.
- Live. Live video plays about 11 seconds behind the stadium, at most 15. If one of the two live encoding chains fails, viewers lose at most one 2-second segment.
1.6 The numbers
These are rough sums, the kind a candidate does at a whiteboard in a few minutes. Every number is our own assumption.
Walnut Flix has 330 million accounts, and members watch 550 million hours a day. About half of all viewing falls in a 4-hour evening, so the busy hour is about 3 times the daily average. We keep capacity for 3.5 times the average all the time, and call that the design peak.
| Number | How we get it | Result | What it decides |
|---|---|---|---|
| Streams at once | 550 million hours × 60 = 33 billion minutes a day. ÷ 1,440 minutes = 22.9 million on average. × 3.5 at the design peak | About 80 million streams at once | Every part on the play path is sized for 80 million streams, not for the average |
| Bytes out | TVs watch at about 6 Mbit/s, phones at 1.5, computers at 3. With 70%, 20% and 10% of the minutes, the average is 4.8 Mbit/s. 80.2 million × 4.8 Mbit/s | About 385 Tbit/s | No cloud region can send this. The bytes come from boxes inside the internet providers, and the cloud only runs the small calls |
| Catalog against one box | 20,000 titles hold 60,000 hours. All 13 rungs and the audio take about 21 GB an hour, so 1.26 PB. An ISP box has 100 TB and keeps only the 5 most-watched rungs and 2 audio languages: 215.4 MB a minute, so 7,737 hours | One ISP box holds about 13% of the catalog | Each box needs the right 13%. A forecast of what each country will watch decides what to copy each night |
| Plays a second | A play lasts 45 minutes on average. 33 billion ÷ 45 = 733 million a day. ÷ 86,400 s × 3.5 | About 30,000 play starts a second | The play path is small cloud services. Each start makes one write, to take a slot |
| Position updates | 33 billion heartbeats a day, one a minute, plus about 3 billion start, pause, seek and stop events. 36 billion ÷ 86,400 × 3.5 | About 1.46 million writes a second | Positions go through a log to a key-value store with one row per profile and title. A new write replaces the old one |
| License renewals | 80.2 million streams each renew every 2 minutes: 80.2 million ÷ 120 s | About 668,000 a second | The slot is renewed by the license renewal, not by its own call. The Slot store is sized for 668,000 renewals a second |
| Encoding | About 40 hours of new runtime a day: 2,400 minutes × 40 CPU-hours a minute. A CPU-hour is one processor core busy for one hour | 96,000 CPU-hours a day | Encoding is batch work that nobody waits on. A title is cut into pieces of about 60 seconds so many machines work on it at once |
| A live game | 24 million US streams × 4 Mbit/s. About 30% of our 472 Tbit/s of boxes are in the US: 141.6 Tbit/s. A US evening uses 99 Tbit/s, and a quarter of those viewers switch to the game, so 74 Tbit/s stay | 96 Tbit/s for the game, 67 Tbit/s free | We book extra bytes from rented CDNs for the night of a big game, and we prepare for millions of devices that press play again at once |
What these numbers tell us. The cloud work is small: 30,000 starts and 1.46 million tiny writes a second. The hard parts are elsewhere:
- 385 Tbit/s must already sit inside the internet providers when the viewer presses play;
- each box holds only 13% of the catalog, so the forecast must pick the right files;
- a live game has nothing to copy ahead of time, and its peak is bigger than our boxes' free capacity.