List the key functional requirements for the system (Ask the AI for hints if stuck)...
List the key non-functional requirements (performance, scalability, reliability, etc.)...
Define the APIs expected from the system. This is your chance to analyze and define the read and write paths so that you can come up with the high-level design...
update count: POST count (accepts positive integer only)
view count: GET count
{"userID": "acbde" }videoID": "12345", "totalViews": 15000, "uniqueViews": 12000 }Describe the overall system architecture. Identify the main components needed to solve the problem end-to-end. Use the diagramming tool to create a block diagram.
For DB we will use simple key value store, as its good for high write and read throughput. Consistency is not a big dealbreaker here.
This architecture is designed for high scalability and allows you to maintain eventual consistency, as specified in your requirements.
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.
How we will scale this:
Sharding:
VideoID, ensuring that each shard contains data for a distinct set of videos, which helps distribute the load evenly across shards.UserID for tables where user-specific data is important, such as ViewHistory.Partitioning:
ViewHistory to split data by time intervals (e.g., daily or monthly partitions) to optimize query performance and data management.Replication Strategy:
ViewCount and Video tables use synchronous replication to ensure data consistency across primary nodes.ViewHistory), use asynchronous replication for eventual consistency, reducing latency during write operations.