How does Netflix scale push messaging for millions of devices?
This post draws from an article published on Netflix’s engineering blog. Here’s my understanding of how the online streaming giant’s system works.
𝐑𝐞𝐪𝐮𝐢𝐫𝐞𝐦𝐞𝐧𝐭𝐬 & 𝐬𝐜𝐚𝐥𝐞
- 220 million users
- Near real-time
- Backend systems need to send notifications to various clients
- Supported clients: iOS, Android, smart TVs, Roku, Amazon FireStick, web browser
𝐓𝐡𝐞 𝐥𝐢𝐟𝐞 𝐨𝐟 𝐚 𝐩𝐮𝐬𝐡 𝐧𝐨𝐭𝐢𝐟𝐢𝐜𝐚𝐭𝐢𝐨𝐧 1. Push notification events are triggered by the clock, user actions, or by systems.
2. Events are sent to the event management engine.
3. The event management engine listens to specific events and forward events to different queues. The queues are populated by priority-based event forwarding rules
4. The “event priority-based processing cluster” processes events and generates push notifications data for devices
5. A Cassandra database is used to store the notification data.
6. A push notification is sent to outbound messaging systems.
7. For Android, FCM is used to send push notifications. For Apple devices, APNs are used. For web, TV, and other streaming devices, Netflix’s homegrown solution called ‘Zuul Push’ is used.
Over to you: if you wanted to support every kind of device, which delivery model would work better, push or pull-based notifications?
Subscribe to our weekly newsletter to learn something new every week ⇩:
The diagram below shows the process. Note that the architectures for different databases are different, the diagram demonstrates some common designs.
Step 1 - A SQL statement is sent to the database via a transport layer protocol (e.g.TCP).
Step 2 - The SQL statement is sent to the command parser, where it goes through syntactic and semantic analysis, and a query tree is generated afterward.
Step 3 - The query tree is sent to the optimizer. The optimizer creates an execution plan.
Step 4 - The execution plan is sent to the executor. The executor retrieves data from the execution.
Step 5 - Access methods provide the data fetching logic required for execution
/1 Amazon DynamoDB powered 89 million requests per second during prime days. How does it do that?
The diagrams below are my attempt to draw the latest architecture of DynamoDB based on the 2022 paper. Please leave a comment if you spot any mistakes.
/1 Why is the credit card called “𝐭𝐡𝐞 𝐦𝐨𝐬𝐭 𝐩𝐫𝐨𝐟𝐢𝐭𝐚𝐛𝐥𝐞 product in banks”? How does VISA/Mastercard make money?
The diagram below shows the economics of the credit card payment flow.
1. The cardholder pays a merchant $100 to buy a product.
/2 2. The merchant benefits from the use of the credit card with higher sales volume and needs to compensate the issuer and the card network for providing the payment service. The acquiring bank sets a fee with the merchant, called the “𝐦𝐞𝐫𝐜𝐡𝐚𝐧𝐭 𝐝𝐢𝐬𝐜𝐨𝐮𝐧𝐭 𝐟𝐞𝐞.”
/3 3 - 4. The acquiring bank keeps $0.25 as the 𝐚𝐜𝐪𝐮𝐢𝐫𝐢𝐧𝐠 𝐦𝐚𝐫𝐤𝐮𝐩, and $1.75 is paid to the issuing bank as the 𝐢𝐧𝐭𝐞𝐫𝐜𝐡𝐚𝐧𝐠𝐞 𝐟𝐞𝐞. The merchant discount fee should cover the interchange fee.
1. How do video live streamings work on YouTube, TikTok live, or Twitch? The technique is called live streaming.
Livestreaming differs from regular streaming because the video content is sent via the internet in real-time, usually with a latency of just a few seconds.
2. The diagram below explains what happens behind the scenes to make this possible.
Step 1: The raw video data is captured by a microphone and camera. The data is sent to the server side.
3. Step 2: The video data is compressed and encoded. For example, the compressing algorithm separates the background and other video elements. After compression, the video is encoded to standards such as H.264.
The size of the video data is much smaller after this step.
1. Twitter and Reddit support NFT (Non-Fungible Token) profile pictures. Do you know what the differences between NFT profile pictures and regular profile pictures are?
The diagram below shows how NFT and regular images differ.
2. 𝐑𝐞𝐠𝐮𝐥𝐚𝐫 𝐩𝐫𝐨𝐟𝐢𝐥𝐞 pic
🔹Step 1: The user uploads a profile picture, and this request goes to the user service
🔹Step 2: The picture is stored in an object store, like Amazon S3. A URL is generated to visit the file
🔹Step 3: The picture’s metadata is stored in DB
3. 𝐍𝐅𝐓 𝐩𝐫𝐨𝐟𝐢𝐥𝐞 image
🔹Step 1: To understand the process, we should know what smart contracts are. Smart contracts are programs deployed and stored on blockchains. They are self-executing when predetermined conditions are met. This is when an NFT is “minted.”