Discover more from System Design Newsletter
How Does Netflix Work?
#22: Learn More - What Happens When You Press Play? (4 minutes)
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 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.
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 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
Consider subscribing to get simplified case studies delivered straight to your inbox:
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.