System Design Newsletter

Share this post

How Does Netflix Work?

newsletter.systemdesign.one

Discover more from System Design Newsletter

Weekly newsletter on system design. Get the powerful system design template for FREE
Over 18,000 subscribers
Continue reading
Sign in

How Does Netflix Work?

#22: Learn More - What Happens When You Press Play? (4 minutes)

NK
Nov 16, 2023
41
Share this post

How Does Netflix Work?

newsletter.systemdesign.one
6
Share

Get the powerful template to approach system design for FREE on newsletter sign-up:


Netflix has 247 million subscribers.

But 99.99% of them don’t know what happens when they press play on Netflix.

This post outlines how Netflix works.

Netflix Architecture

Netflix architecture consists of the client, backend, and content delivery network (CDN).

Netflix architecture
Cartoon Architecture of Netflix

The user interface to browse and play Netflix videos is called the client. It could be a mobile app, a web browser, or a smart TV app.

The backend runs on the AWS cloud. It handles everything that happens before the play button gets pressed. For example, content personalization and payment processing.

While CDN handles everything that happens after the play button gets pressed. Netflix uses a custom CDN called Open Connect Appliance (OCA). It’s used to store and stream videos to the client.


The .NET Weekly (Featured)

The .NET Weekly

Want to become a better software engineer? Each week, Milan sends one piece of practical advice about .NET and software architecture. It's a 5-minute read (or less) and comes every Saturday morning. Join 32,000+ engineers here:

Try it


Netflix on AWS

Netflix runs its backend on AWS because it’s cheaper. It allows Netflix to add servers when needed and return them when not needed anymore. So Netflix pays for only what is needed.

Netflix on AWS
AWS Elasticity

Netflix runs around 700 microservices and uses DynamoDB and Cassandra databases.

Also they run their backend on many availability zones and AWS regions for reliability.


Netflix Open Connect Appliance

Netflix created its own CDN for storing and streaming videos. Because they wanted the highest network efficiency.

Netflix Open Connect Appliance
Open Connect Appliance

They built OCA with commodity hardware and optimized it for delivering large files. It runs the FreeBSD operation system and Nginx webserver.

When you press play, the Netflix client finds the nearest OCA and streams the video from it.

Besides Netflix client automatically switches to another OCA if the network gets overloaded or if the active OCA fails.

Netflix OCA Streaming
Netflix Streaming Content from OCA

Netflix keeps OCA closer to your house by installing it at your internet service provider (ISP). This allows Netflix to scale and offer the best streaming experience. The ISP is the one that provides you with home internet like Vodafone, Comcast, or Verizon.

Also Netflix would consume more bandwidth if ISPs didn’t install OCA. And cause network congestion. Put another way, ISPs would have to buy more network capacity without OCA.

So it's a win-win situation for both ISPs and Netflix.

Besides Netflix predicts the videos you’ll want to watch and store them in OCA. The videos then get copied to the OCA during off-peak hours one day in advance to reduce bandwidth usage for ISPs.

The benefits of Open Connect Appliance are:

  • High-quality streams by controlling the entire video path

  • Less expensive compared to cloud-based CDN

  • More scalable by owning the system


Netflix Transcoding

Netflix supports 2200 different types of devices. But each device has a specific video format that works best on it. So they convert each video into many formats.

When you press play, Netflix determines the client that you use and fetches the specific file for your device type.

Netflix transcoding
Transcoding Video

Production houses and studios send high-definition videos to Netflix. The original video gets stored on AWS S3 servers. Netflix then converts the video into many formats to support different devices.

The process of converting a video into a different format is called transcoding. The videos get transcoded in parallel for fast delivery.

Also each video gets split into many chunks to support adaptive bitrate streaming. Adaptive bitrate streaming allows switching video quality as network conditions change.

A poor network condition results in a lower-resolution stream. While a stable network results in a higher-resolution stream.

Besides a special code gets added to the files to prevent piracy. It is called digital rights management (DRM). It encrypts the video content and prevents unauthorized access.


How Does Netflix Stream Video?

How Does Netflix Stream Video?
What Happens When You Press Play?

Here is how Netflix streams a video when you press play:

  1. Netflix client sends a play request to the backend service on AWS

  2. The backend service returns the URLs to the 10 best OCA servers based on your IP address

  3. Netflix client intelligently selects the best OCA. It does that by testing the network connection quality

  4. Netflix client connects to the OCA and streams the video


Consider subscribing to get simplified case studies delivered straight to your inbox:


Author NK; System design case studies
Follow me on LinkedIn and Twitter

Thank you for supporting this newsletter. You are now 14,821+ subscribers strong, very close to 15k. I think we can get to 15k subscribers by 21 November.

Consider sharing this post with your friends and get rewards. Y’all are the best.

System design newsletter

Share


Microservices Lessons From Netflix

Microservices Lessons From Netflix

NK
·
Oct 31
Read full story
How Discord Boosts Performance With Code-Splitting

How Discord Boosts Performance With Code-Splitting

NK
·
Nov 8
Read full story

  • https://openconnect.netflix.com/

  • https://netflixtechblog.com/

  • https://medium.com/refraction-tech-everything/how-netflix-works-the-hugely-simplified-complex-stuff-that-happens-every-time-you-hit-play-3a40c9be254b

  • http://highscalability.com/blog/2017/12/11/netflix-what-happens-when-you-press-play.html

  • https://arstechnica.com/information-technology/2022/10/redditor-acquires-decommissioned-netflix-cache-server-with-262tb-of-storage/

41
Share this post

How Does Netflix Work?

newsletter.systemdesign.one
6
Share
Previous
Next
6 Comments
Share this discussion

How Does Netflix Work?

newsletter.systemdesign.one
ECecillo
Nov 29Liked by NK

Straight to the point while giving you some information to dig deeper.

Good job!

However, if I understand correctly once the EC2 instance transcodes the video it gets sent to the OCA that stores it and provides the chunk of video as fast as possible?

Between, do you know how these videos are transferred to the OCA and if there is a lot more process and optimization that goes into it?

Expand full comment
Reply
Share
3 replies by NK and others
Jordan Cutler
Writes High Growth Engineer
Nov 21Liked by NK

One of the best explanations to Netflix architecture. Easy to understand and technically deep as always. Thank you, NK!

Expand full comment
Reply
Share
1 reply by NK
4 more comments...
Top
New
Community

No posts

Ready for more?

© 2023 NK
Privacy ∙ Terms ∙ Collection notice
Start WritingGet the app
Substack is the home for great writing