Designing Netflix

1 billion videos watched a day · Part of Interview cases

Key idea

Practice

7 questions · about 4 min

Explained step by step

Functional requirement

Functional: watch and share videos, the content team uploads new videos, search by title or tags, and comment. Non-functional: high availability with minimal latency, high reliability with no lost uploads, and it must scale. Extended: block content by region, resume where you left off, and metrics. It's like a giant video store: renting is the basics, remembering the minute you stopped is an extra.

Estimation

With 200 million daily active users watching 5 videos each, that's 1 billion plays per day: about 12,000 requests per second. With a 200 to 1 ratio, about 5 million videos are uploaded per day. If each weighs 100 MB, that's 500 TB per day; over 10 years, about 1,825 PB. To receive 500 TB per day you need about 5.8 GB per second of bandwidth. It's like calculating how many movies fit in a warehouse receiving 5 million boxes a day.

Transcoding

A raw 2-hour 8K video can weigh 4 TB, so it's processed to cut cost. When uploaded, it goes into a message queue and through 4 steps: the chunker splits it into pieces; the content filter checks copyright, piracy and unsafe content with machine learning; the transcoder decodes it and re-encodes it into the target format; and quality conversion produces several resolutions, like 4K, 1080p and 720p. A queue is used because it's a long task and that decouples it from the upload. It's like a jam factory: wash, inspect, cook and fill jars of different sizes.

Transcoding is decoding the original into an uncompressed intermediate format and then encoding it into the target format, using different codecs to adjust bitrate, downscale the image or change the format. The result weighs less and fits each device. It can be done with FFmpeg or AWS Elemental MediaConvert. Then quality conversion produces 4K, 1440p, 1080p and 720p, stored in distributed storage like HDFS or S3. It's like translating a book: reading it in the original language and writing it in each reader's language.

Chunking

Splitting a file into pieces, or chunks, avoids storing repeated copies and lets you send only the changed pieces. The usual way is splitting a video into equal pieces by time, but Netflix splits by scenes. That difference greatly improves the experience: each request brings a whole scene, so there are fewer interruptions while watching. If the content filter finds a problem, the video goes to a dead-letter queue for someone to review. It's like cutting a pizza into natural slices instead of exact squares.

Adaptive bitrate

To avoid sending the same content again and again from far away, a CDN is used. Netflix goes further with Open Connect: its own CDN with appliances inside thousands of internet providers, in over 1,000 locations, carrying about 95% of its traffic. Also, adaptive bitrate streaming, like HLS, adjusts quality to each user's connection on the fly. And to resume where you left off, the offset stored in the views table is used. It's like a water tap in every neighborhood instead of bringing it from the dam every time.

Geo-blocking

Netflix uses geo-blocking to restrict content in certain countries, due to distribution contracts. The location comes from the IP or the profile's region, and it's applied with features like CloudFront's geographic restrictions. To recommend, it uses machine learning on the history: something like collaborative filtering, which suggests what similar users watched. It also looks at age, country, how you browse, what time you watch, the device and what you searched. It's like a bookseller who knows you: they don't show what's banned in your country and recommend what others with your taste read.

Terms in this lesson

Arki, the beaver mascot

Your next interview starts with 5 minutes today.

Free on iOS and Android. Start from zero, no account needed.

Key idea

1 billion videos watched a day