ByteByteGo 2024年07月11日
How Netflix Manages 238 Million Memberships?
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

本文深入探讨了 Netflix 会员平台的架构设计,涵盖了会员生命周期管理、高可用性架构、数据跟踪和 CDC 模式等关键方面,并以图文并茂的方式展示了会员注册流程和会员历史数据的追踪机制。

🤔 Netflix 会员平台是一个关键系统,负责管理用户订阅的整个生命周期,包括注册、计划变更、续订、支付问题、暂停和取消等。该平台需要高可用性和可扩展性才能满足全球 2.38 亿用户的需求。

🖥️ Netflix 会员平台采用微服务架构,由多个独立的微服务组成,并通过 CockroachDB 和 Cassandra 数据库进行数据存储。其中,CockroachDB 用于存储计划定价信息,Cassandra 用于存储会员数据。

📈 为了确保会员历史数据完整性和可追溯性,Netflix 采用了一种基于 CDC(变更数据捕获)模式的数据跟踪机制。该机制将所有对会员数据源的增量更改记录到一个追加式日志系统中,该系统由 Cassandra 数据库支持。

🚀 Netflix 会员平台的架构设计充分体现了 Netflix 对高可用性、可扩展性和数据一致性的重视。通过微服务架构、数据库选择和 CDC 模式,Netflix 能够有效地管理其庞大的会员群体,并提供稳定可靠的服务体验。

Guide to Accelerating DevOps Transformation (Sponsored)

The DevOps model can engender faster development cycles and enhanced agility in responding to market needs.

Datadog's DevOps Kit gives you the resources to create and strengthen cultures of observability, collaboration, and data sharing within organizations—key pillars of the DevOps movement.

Gain instant access to:


Disclaimer: The details in this post have been derived from the articles/presentations made by the Netflix engineering team. All credit for the architectural details goes to the Netflix engineering team. The links to the original articles are present in the references section at the end of the post. We’ve attempted to analyze the details and provide our input about them. If you find any inaccuracies or omissions, please leave a comment, and we will do our best to fix them.

As a subscription-based streaming service, Netflix's primary revenue source is its membership business. With a staggering 238 million members worldwide, managing memberships efficiently is crucial for the company's success and continued growth. 

The membership platform at Netflix plays a vital role in handling the entire lifecycle of a user's subscription.

The membership lifecycle consists of various stages and scenarios:

In the following sections, we will explore the architectural decisions made by the Netflix engineering team to support the various capabilities and scalability of its membership platform.


The High-Level Architecture of Netflix Membership Platform

Before diving into the details of Netflix's membership platform, let's take a step back and examine how the company's original pricing architecture was designed. 

In the early days, Netflix's pricing model was relatively straightforward, with only a handful of plans to manage and basic functionality to support.

To meet these initial requirements, Netflix employed a lightweight, in-memory library. This approach proved to be quite efficient, as the limited scope of the pricing system allowed for a simple and streamlined design.

The diagram below illustrates this basic architecture:

As Netflix expanded its global presence and diversified its offerings, the lightweight, in-memory library that initially served the pricing architecture became insufficient. 

The growing complexity and scope of the pricing catalog, coupled with its increasing importance across multiple applications, led to operational challenges. The library's size and dependencies made it difficult to maintain and scale, necessitating a transition to a more robust and scalable architecture.

The diagram below shows the high-level architecture of Netflix’s modern membership platform:

The membership platform consists of a dozen microservices and is designed to support four nines (99.99%) availability. 

This high availability requirement originates from the platform's critical role in various user-facing flows. If any of the services experience downtime, it can directly impact the user experience.

The platform supports several key functionalities:

The key points about the architecture diagram are as follows:

Netflix’s choice of using CockroachDB and Cassandra is interesting. 

While CockroachDB provides strong consistency, making it suitable for critical data such as the plan pricing information, Cassandra is a highly scalable NoSQL database for handling large volumes of membership data.

Also, the 99.99% availability indicates a strong focus on resilience and fault tolerance. Netflix is anyways famous for its comprehensive chaos engineering practices to proactively test the system’s resilience.


Latest articles

If you’re not a paid subscriber, here’s what you missed.

    A Crash Course on Microservice Communication Patterns

    A Crash Course on Cell-based Architecture

    A Crash Course on Content-Delivery Networks (CDN)

    A Crash Course on REST APIs

    API Security Best Practices

To receive all the full articles and support ByteByteGo, consider subscribing:

Subscribe now


The Signup Process Flow

Once users embark on their Netflix journey, they encounter plan selection options.

Rendering the plan selection page accurately is of utmost importance due to the geographical variations in currency, pricing, and available plans. Netflix's membership platform ensures that users are presented with the appropriate options based on their location and device type.

The diagram below shows the detailed steps involved in the Netflix signup process and the services that are triggered during the flow:

Here’s a look at each step in more detail.

    The journey begins with users selecting a plan through Netflix's growth engineering apps. The plan details are retrieved from the Membership Plan Catalog service, which is backed by CockroachDB. 

    The Membership Plan Catalog Service loads and reads the plans based on predefined region and device type rules.

    The retrieved plans are then presented to the user, allowing them to make an informed decision based on their preferences and budget.

    Once the user chooses a plan, the flow progresses to the payment confirmation screen. Here, users provide their payment details and confirm their subscription.

    Upon confirmation, the user clicks the "Start Membership" button, triggering the Membership State Service. This service persists the relevant information, such as the selected plan, price tier, and country, into the Cassandra database.

    The Membership State Service also notifies the Billing Engineering Apps about the payment. 

    The Billing Engineering Apps generate an invoice based on the signup data obtained from the Membership Pricing Service.

    The membership data is simultaneously written to the Membership History Service, ensuring a comprehensive record of the user's subscription history.

    Events are published to signal the activation of the membership. These events trigger messaging pipelines responsible for sending welcome emails to the user and informing downstream systems for analytics purposes.

How Member History Is Tracked?

In the early stages of Netflix's membership platform, member history and data were tracked through application-level events. 

While this approach sufficed initially, it became evident that a more granular and persistent data tracking solution was necessary as Netflix expanded and the complexity of member data increased.

To address this need, Netflix developed a robust solution based on the Change Data Capture (CDC) pattern. 

For reference, CDC is a design pattern that directly captures changes made to a database and propagates those changes to downstream systems for further processing or analysis.

The diagram below shows how the CDC process works:

Adopting a CDC-like approach ensures that all delta changes made to the membership data sources are recorded in an append-only log system, which is backed by a Cassandra database.

The diagram below shows the flow of historical data in Netflix’s membership platform:

Let’s walk through the steps in this process:

    Suppose there is an update request to modify the billing partner for a member. The request is received by the Membership Subscription Service.

    The Membership Subscription Service processes the request and updates the relevant information in the Cassandra database.

    In addition to updating the primary database, the updated data for the user is appended to the Membership History Service. This service is responsible for maintaining a historical record of all changes made to membership data.

    The Membership History Service takes the appended data and inserts it into the Member History Table. This table serves as a persistent store for the historical data.

    Finally, an event is emitted to notify downstream systems about the membership update. This allows other services and processes to react to the change and perform any necessary actions.

There are multiple benefits to this design:

Technical Footprint of the Netflix Membership Platform

The technical landscape of the Netflix membership platform can be broadly categorized into two main areas: development and operations/monitoring. 

Let's look at each area in detail.

Development Stack

The development stack of Netflix’s membership platform can be described by the following key points:

Operations and Monitoring

Netflix places a strong emphasis on observability and monitoring to ensure the smooth operation of its membership platform:

Conclusion

In conclusion, Netflix's membership platform is a critical component of the company's success, enabling it to manage the entire lifecycle of a user's subscription. The platform has evolved from a simple, lightweight library to a robust, scalable architecture that can handle millions of requests per second

Some key takeaways to remember are as follows:

References:


SPONSOR US

Get your product in front of more than 500,000 tech professionals.

Our newsletter puts your products and services directly in front of an audience that matters - hundreds of thousands of engineering leaders and senior engineers - who have influence over significant tech decisions and big purchases.

Space Fills Up Fast - Reserve Today

Ad spots typically sell out about 4 weeks in advance. To ensure your ad reaches this influential audience, reserve your space now by emailing hi@bytebytego.com


Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

Netflix 会员平台 架构 微服务 CDC 数据跟踪
相关文章