Design Netflix
hard 45 minPaying members press play and a film starts within two seconds, in the quality they paid for.
Video lesson · Chapter 1 of 5
Press Play while a million other viewers press it too
Filled the night before, in 90 seconds
1:30Reel coming soon
Theory
Read or listen first. About 2 min.
What it is
A subscription streaming service lends a chosen library of films and series to paying members on any screen. Each play is a question (may this account watch this title here, now?) followed by a long stream of bytes.
The question is answered by the control plane: accounts, plans, licences, positions, home pages. The bytes come from the data plane: boxes with disks, close to the viewers, that know nothing about people.
Why it exists
The bytes are enormous: we assume 29 million streams at the same time, 144 Tb/s. The questions are small: about a million requests a second, mostly heartbeats. Different loads deserve different systems.
The library is small: 17,000 titles are about 2 PB in all qualities. That fits on 18 machines of the size we assume, so a place can hold everything, or the part that people will want tomorrow. A public upload site cannot do that.
A short history
August 2008 to January 2016
By its own account, Netflix starts to move to the cloud after a database corruption in 2008 and shuts down the last streaming data center parts in early January 2016.
2011
Netflix begins Open Connect, its own delivery network with caches that are filled ahead of demand, says its overview paper.
August 2014
A SIGCOMM paper shows a player that chooses quality from its buffer, tested with users of a commercial service.
September 2017
Encrypted Media Extensions become a W3C Recommendation: a web page can ask the browser's licence system to play protected video.
Words to know
- Control plane
- Services that decide: who, what, from where.
- Data plane
- Machines that send the bytes.
- Edge box
- Our cache server in a provider's network or at an exchange.
- Fill
- Copying files to boxes before anyone asks.
- Steering
- Choosing which boxes a device should use.
- DRM
- Digital rights management: files are encrypted, and a licence carries the key and its rules.
- Ladder
- The qualities of a title, from lowest to highest.
- VMAF
- A score from 0 to 100 for how good a picture looks, developed by Netflix and open source.
- Lease
- A right that ends by itself unless it is renewed.
Solve it like an interview
New to it? Start with Approach. Revising? Go straight to the mock.
- 1ApproachWhat this question tests, where it gets hard, and how to spend the time.
- 2ScopeAsk what changes the design, then commit to a short list.
- 3NumbersWork out a number when the answer changes what you build.
- 4API and dataThe contract first, then the data that serves it.
- 5DesignStart with the smallest system that works. Change it only when something breaks.
- 6Deep divesCompare the options before you open them, then say which you would pick.
- 7Explain your choicesAnswer first. Then compare your reasoning.
- 8By levelThe same question is judged differently for mid, senior and staff.
- 9MockAnswer against the clock, then score yourself.
Understand it
Picture it
Film tins on village shelves
Plan by day, carry by night, open with a key, and know the next shelf.
Scope
What are we building?
A service like Netflix: browse, play, continue later, download. Numbers are our assumptions. Where we say what Netflix does, the sentence comes from its own pages, listed under sources.
Encode once
A ladder for each title, since a cartoon needs fewer bits than a battle.
Fill early
Known library, predicted demand, quiet nights.
Decide quickly
Plan, country, age, streams, licence: in one call.
Keep playing
Next box, lower quality, another region.
Similar services
The finished system
Where the design ends up
The whole system
Read next
Who owns which idea
| Idea | Its own page |
|---|---|
| Uploads, splitting, parallel encoding | YouTube |
| Tiers, push and pull | CDN design |
| A CDN for many customers | Content delivery network |
| Candidates and ranking | Recommendation system |
| Breakers, fallbacks, timeouts | Circuit breaker, Fallbacks, Timeouts |
| Several regions | High availability stacks |
| Tables for each question | NoSQL |
| Changes as a stream | Change data capture |
| Old devices | API versioning |
| Many requests at one moment | Thundering herd |
For the interview: Approach, then Scope, Numbers, API and data, Design and Deep dives. For revision, go to the Mock.
Summary
The whole topic in one minute.
Encode each title once and carefully, then place the files near viewers at night by predicted demand. In the evening the control plane checks the account, gives a licence, and returns a list of boxes. The player fetches segments, chooses quality from its buffer, and moves to the next box if one fails.
Everything around that is small data with clear rules: a lease for each running stream, positions that are saved now and then, home pages that are computed ahead, and several regions that can each take over.
- 144 Tb/s of bytes and one million small requests a second are two systems.
- 2 PB fits in one exchange site, so origin reads are rare.
- Place by views for each gigabyte, at night.
- The buffer is the safety net: fill it first, then raise quality.
- A stream is a lease. Nobody has to press stop.
- Running films survive a control plane failure; new plays need another region.
Sources
- Netflix: Open Connect overview (PDF)
- Netflix: Open Connect appliances
- Huang and others: a buffer-based approach to rate adaptation (SIGCOMM 2014, PDF)
- Netflix: completing the cloud migration
- VMAF
- Chaos Monkey
- Hystrix (status: maintenance mode)
- EVCache
- Encrypted Media Extensions
- Netflix Help: plans and streams
- Netflix Help: profiles