Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Design: Netflix Streaming Platform
Design covers backend microservices, data storage, content delivery, user authentication, recommendation engine, and monitoring. Does not cover content licensing or DRM details.
Functional Requirements
FR1: Support streaming video content to 200 million+ users worldwide
FR2: Allow users to browse, search, and play movies and TV shows
FR3: Personalize content recommendations based on user preferences
FR4: Handle peak traffic during popular show releases
FR5: Ensure high availability with minimal downtime
FR6: Support multiple device types (smart TVs, phones, tablets, web)
FR7: Secure user data and prevent unauthorized access
FR8: Provide analytics on user engagement and streaming quality
Non-Functional Requirements
NFR1: Scale to handle 10 million concurrent streams
NFR2: API response latency under 200ms for browsing and searching
NFR3: Streaming latency under 5 seconds from play request
NFR4: Availability target of 99.9% uptime
NFR5: Global distribution with low latency access
NFR6: Data consistency for user profiles and watch history
NFR7: Cost-effective use of cloud resources
Think Before You Design
Questions to Ask
❓ Question 1
❓ Question 2
❓ Question 3
❓ Question 4
❓ Question 5
❓ Question 6
❓ Question 7
Key Components
API Gateway
User Authentication Service
Content Management Service
Streaming Service
Recommendation Service
Search Service
User Profile Service
Content Delivery Network (CDN)
Database (SQL/NoSQL)
Cache (Redis/Memcached)
Monitoring and Logging
Design Patterns
Microservices architecture
Event-driven communication
CQRS (Command Query Responsibility Segregation)
Cache-aside pattern
Circuit breaker for fault tolerance
Load balancing
Data partitioning and replication
Reference Architecture
+-------------------+
| User Devices |
+---------+---------+
|
v
+-------------------+
| API Gateway |
+---------+---------+
|
+---------------------+---------------------+
| | |
v v v
+---------+ +-----------+ +-----------+
| Auth | | Search | | Profile |
| Service | | Service | | Service |
+----+----+ +-----+-----+ +-----+-----+
| | |
v v v
+-------------------------------------------------------+
| Recommendation Service |
+-------------------------------------------------------+
|
v
+-------------------+
| Streaming Service |
+---------+---------+
|
v
+-------------------+
| CDN |
+-------------------+
Additional components:
- Databases for user data, content metadata, and recommendations
- Cache layers for fast data access
- Monitoring and logging infrastructure
Components
API Gateway
Nginx / Envoy
Entry point for all client requests; routes requests to appropriate microservices; handles rate limiting and authentication checks
User Authentication Service
OAuth 2.0, JWT
Manages user login, token issuance, and session validation
Search Service
Elasticsearch
Provides fast search capabilities over movie and show metadata
User Profile Service
PostgreSQL / Cassandra
Stores user preferences, watch history, and account details
Recommendation Service
Machine Learning models, Apache Kafka
Generates personalized content recommendations based on user behavior and preferences
Streaming Service
Microservices with adaptive bitrate streaming (HLS/DASH)
Handles video stream requests, manages session state, and interacts with CDN
Content Delivery Network (CDN)
Akamai / CloudFront
Delivers video content globally with low latency and high availability
Cache
Redis / Memcached
Caches frequently accessed data like user sessions, recommendations, and metadata to reduce latency
Monitoring and Logging
Prometheus, Grafana, ELK Stack
Tracks system health, performance metrics, and logs for troubleshooting
Request Flow
1. User sends request from device to API Gateway.
2. API Gateway authenticates request via Authentication Service.
3. For browsing or searching, API Gateway routes to Search Service or Profile Service.
4. User preferences and watch history fetched from Profile Service and cache.
5. Recommendation Service consumes user data and events to generate personalized lists.
6. User selects content to play; Streaming Service receives request.
7. Streaming Service coordinates with CDN to deliver video stream.
8. CDN serves video chunks to user device with minimal latency.
9. Monitoring services collect metrics and logs throughout the flow.
Database Schema
Entities:
- User: user_id (PK), email, password_hash, subscription_status
- Profile: profile_id (PK), user_id (FK), preferences, watch_history
- Content: content_id (PK), title, genre, metadata, availability
- Recommendation: user_id (FK), content_id (FK), score
- SearchIndex: content_id (FK), keywords
Relationships:
- One User has many Profiles
- Profiles link to multiple Recommendations
- Content referenced in Recommendations and SearchIndex
Scaling Discussion
Bottlenecks
API Gateway becoming a single point of failure under high load
Database write and read throughput limits for user data
Recommendation Service processing delays with large user base
Streaming Service bandwidth and session management under peak load
CDN cache misses causing higher latency
Solutions
Deploy multiple API Gateway instances behind load balancers for redundancy and scale
Use database sharding and read replicas to distribute load; employ NoSQL stores for high write throughput
Implement asynchronous event processing and batch updates in Recommendation Service; use scalable ML infrastructure
Scale Streaming Service horizontally; use stateless session management and autoscaling
Optimize CDN caching strategies; pre-warm caches for popular content; use multi-CDN approach
Interview Tips
Time: Spend 10 minutes understanding requirements and clarifying scope, 20 minutes designing architecture and data flow, 10 minutes discussing scaling and trade-offs, 5 minutes summarizing.
Explain microservices and their responsibilities clearly
Highlight how CDN reduces latency for streaming
Discuss caching to improve performance and reduce DB load
Describe personalization via recommendation engine
Address fault tolerance and high availability strategies
Mention monitoring for proactive issue detection
Show awareness of trade-offs between consistency and availability
Practice
(1/5)
1. What is the main reason Netflix uses microservices in its architecture?
easy
A. To make the system monolithic and simple
B. To use a single large database for all data
C. To avoid using APIs for communication
D. To break down the system into smaller, manageable parts
Solution
Step 1: Understand microservices purpose
Microservices divide a large system into smaller parts that are easier to manage and update.
Step 2: Relate to Netflix architecture
Netflix uses microservices to handle specific functions separately, improving scalability and maintenance.
Final Answer:
To break down the system into smaller, manageable parts -> Option D
Quick Check:
Microservices = Smaller parts [OK]
Hint: Microservices split big systems into small parts [OK]
Common Mistakes:
Thinking microservices avoid APIs
Believing Netflix uses one big database
Confusing microservices with monolithic design
2. Which of the following correctly describes how Netflix microservices communicate?
easy
A. Through APIs that allow services to talk to each other
B. Using direct database connections between services
C. By sharing the same memory space
D. Using file system locks to coordinate
Solution
Step 1: Identify communication method in microservices
Microservices communicate via APIs, which are defined interfaces for exchanging data.
Step 2: Match with Netflix architecture
Netflix services use APIs to interact, ensuring loose coupling and independent deployment.
Final Answer:
Through APIs that allow services to talk to each other -> Option A
Quick Check:
Microservices communicate via APIs [OK]
Hint: Microservices talk via APIs, not direct DB or memory [OK]
Common Mistakes:
Assuming services share memory
Thinking services connect directly to databases
Believing file locks coordinate services
3. Consider Netflix's microservice for user recommendations. If this service fails, what is the likely impact on the system?
medium
A. Only the recommendation feature will be affected
B. User login will fail for all users
C. The entire Netflix platform will stop working
D. Video streaming will be interrupted for all users
Solution
Step 1: Understand microservice isolation
Each microservice handles a specific function independently, so failure affects only that function.
Step 2: Apply to recommendation service failure
If the recommendation service fails, only recommendations stop working; other features like login or streaming continue.
Final Answer:
Only the recommendation feature will be affected -> Option A
Quick Check:
Microservice failure affects only its feature [OK]
Hint: Microservice failure affects only its own feature [OK]
Common Mistakes:
Assuming entire platform fails
Confusing recommendation with login or streaming
Thinking microservices share failure impact
4. A developer notices that Netflix microservices are tightly coupled, causing deployment issues. What is the best fix?
medium
A. Increase the database size to handle more data
B. Refactor services to communicate only via APIs and avoid direct calls
C. Use shared global variables for communication
D. Merge all microservices into one big service
Solution
Step 1: Identify tight coupling problem
Tightly coupled services depend directly on each other, causing deployment and scaling problems.
Step 2: Apply microservice best practice
Services should communicate only via APIs to remain independent and deploy separately.
Final Answer:
Refactor services to communicate only via APIs and avoid direct calls -> Option B
Quick Check:
Loose coupling via APIs fixes deployment issues [OK]
Hint: Use APIs to keep services independent and deployable [OK]
Common Mistakes:
Merging services defeats microservice benefits
Using shared variables breaks isolation
Increasing DB size doesn't fix coupling
5. Netflix wants to scale its video streaming microservice during peak hours. Which approach best fits its microservices architecture?
hard
A. Store all streaming data in a single database server
B. Combine streaming with user login service to reduce network calls
C. Deploy multiple instances of the streaming service behind a load balancer
D. Disable other microservices to free resources for streaming
Solution
Step 1: Understand scaling in microservices
Scaling means running multiple copies of a service to handle more users.
Step 2: Apply to streaming service
Deploying multiple streaming service instances with a load balancer distributes user requests efficiently.
Step 3: Evaluate other options
Merging services or disabling others breaks microservice principles; single DB server is a bottleneck.
Final Answer:
Deploy multiple instances of the streaming service behind a load balancer -> Option C
Quick Check:
Scale by multiple instances + load balancer [OK]
Hint: Scale by adding instances and load balancer [OK]