Design Netflix
hard 45 minPaying members press play and a film starts within two seconds, in the quality they paid for.
See it run
A press on play, a film on its way to the boxes, a night of filling, a buffer and a stream limit.
Operations
Press on play
Rights, licence and bytes until the first picture.
Step 1 of 11
Play
device
4K television
The viewer presses the button. The app had fetched the title's data while it was in focus.
Step 1: Play
def start(req): acc = auth(req) check_plan(acc, req.device) check_rights(req.title, acc.country, req.profile.age) if not leases.start(acc, req.session, limit=acc.streams): return 409, "too_many_streams" return 201, {"manifest": manifest(req), "resume_at": pos(req), "boxes": steering.rank(req)}# device: at the same timelicence = fetch_licence(session)init, first = box.get("init"), box.get("seg/1")decoder.show(decrypt(init, first, licence))- Time
- 1.8 s here, 2 s target
- Load
- 1 session, 1 licence
When a title is in focus, the app already fetches its data and opens connections.
In the real world
The same subscription streaming doing real jobs. Pick one and step through it.
Ten million plays in one minute.
Step 1 of 4
Days before
Every box gets the files, hidden until the hour.
Step 1: Days before
Common mistakes
The bugs interviewers watch for, with the fix beside each.
Count streams up and down
criticalA device without power never says stop, and the member is locked out.
Wrongstart: n += 1 stop: n -= 1Rightlease 90 s, renewed by heartbeatsPut members' data on boxes
criticalThe boxes stand in other companies' rooms.
Wrongbox: files + history + keysRightbox: encrypted files onlyPull only
majorEverybody misses in the same evening, over full links.
Wrongon miss: fetch from storageRightnight: copy what tomorrow needsRank by views times size
majorHuge files push out small popular ones.
Wrongkey = views * gbRightkey = views # saved bytes per byte storedA spare region that sleeps
majorIt fails on the one day it is needed.
Wrongregion C: cold standbyRightthree active regions, each with room for a half
Interview tips
Name the lever
- 2.1 PB is small.
- Tomorrow is predictable.
- The night is free.
Keep planes apart
- Decide in the cloud.
- Send from boxes.
- Different failures.
Check units
- 29M × 5 Mb/s: terabits.
- 17,000 titles: petabytes, not exabytes.
- Say units aloud.
Fail softly
- Next box, lower quality.
- Old rows before errors.
- Leases open, payment closed.