List the key functional requirements for the system (Ask the AI for hints if stuck)...
1) Compose a message
2) Read and view other tweets
3) There should be a capping on the max number of characters
4) Like and share the tweet
5) Follow/Unfollow people
List the key non-functional requirements (performance, scalability, reliability, etc.)...
1) Scalable
2) Low latency
3) Reliable and Fault tolerant
4) High Availability and eventual consistency
Estimate the scale of the system. Consider daily active users, read/write ratio, storage requirements, bandwidth, and any relevant QPS calculations...
Daily Active Users -> 1 billion
Considering that only 10% of users are writing tweets -> 10 million
Read/Write ratio : 10:1
Tweet would consist of 250 characters max, that makes it 250 bytes of memory, assume 0.5 KB for simpler calculation.
0.5KB * 10^6 Write requests in a day = 0.5GB ~ 1 GB of memory needed every day. Considering a tweet needs to be stored for 10 years, storage needed for 10 years = 1GB*30*12*10 = ~4TB
Throughput = 1 billion requests each day -> 0.5 billion requests at peak load = 0.5 billion QPS
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...
GET v1/tweets?page=1&limit=10
POST v1/tweets
Request:
tweet{
content: String,
id: String,
userId: String,
}
201 created
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.
Define the data model. Identify the main entities, their attributes, and relationships. Consider the choice of database type (SQL vs NoSQL) and justify your decision based on access patterns...
1) Graph based DB for storing followers and following as this represents a network of connections.
2) Relational DB for storing user details as the data is highly structured and limited.
3) NoSQL DB for storing tweets as the data can grow exponentially and horizontal scaling and low latency will be key benefits to consider NoSQL DB.
Deep dive into 2-3 key components. Explain how they work, how they scale, discuss tradeoffs, capacity, and any relevant algorithms or data structures.