Get the powerful template to approach system design for FREE on newsletter sign-up:
This post outlines how Netflix works. If you want to learn more, scroll to the bottom and find the references.
Share this post & I'll send you some rewards for the referrals.
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).
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)
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:
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 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.
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 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.
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?
Here is how Netflix streams a video when you press play:
Netflix client sends a play request to the backend service on AWS
The backend service returns the URLs to the 10 best OCA servers based on your IP address
Netflix client intelligently selects the best OCA. It does that by testing the network connection quality
Netflix client connects to the OCA and streams the video
👋 PS - Are you unhappy at your current job?
While preparing for system design interviews to get your dream job can be stressful.
Don't worry, I'm working on content to help you pass the system design interview. I'll make it easier - you spend only a few minutes each week to go from 0 to 1. Yet paid subscription fees will be higher than current pledge fees.
So pledge now to get access at a lower price.
“An easy-to-understand view of complex real-world architectures.” Fran
Consider subscribing to get simplified case studies delivered straight to your inbox:
Thank you for supporting this newsletter. Consider sharing this post with your friends and get rewards. Y’all are the best.
References
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/
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?
One of the best explanations to Netflix architecture. Easy to understand and technically deep as always. Thank you, NK!