My Solution for Design Twitter with Score: 3/10
by galaxy9435
System requirements
Functional:
- User Actions:
- Users can post tweets containing up to 140 characters.
- Users can follow and unfollow other users.
- Users can like tweets.
- Feed:
- Users have a feed displaying recent tweets from the users they are following.
- Feed should show popular tweets from across the network based on most likes and followers.
Non-Functional:
- Scalability: Should support up to 500 million daily active users.
- Performance: Users should see their home feed within 500 milliseconds of opening the app.
- Availability: The system should be highly available, with minimal downtime.
Capacity estimation
- 500 million daily active users with each posting around 2 tweets a day, leading to 1 billion tweets daily.
- Users view about 100 tweets a day.
API design
postTweet(user_id, content)
followUser(follower_id, followee_id)
likeTweet(user_id, tweet_id)
getUserFeed(user_id, page_token, number)
Database design
Defining the system data model early on will clarify how data will flow among different components of the system. Also you could draw an ER diagram using the diagramming tool to enhance your design...
High-level design
You should identify enough components that are needed to solve the actual problem from end to end. Also remember to draw a block diagram using the diagramming tool to augment your design. If you are unfamiliar with the tool, you can simply describe your design to the chat bot and ask it to generate a starter diagram for you to modify...
Request flows
Explain how the request flows from end to end in your high level design. Also you could draw a sequence diagram using the diagramming tool to enhance your explanation...
Detailed component design
Dig deeper into 2-3 components and explain in detail how they work. For example, how well does each component scale? Any relevant algorithm or data structure you like to use for a component? Also you could draw a diagram using the diagramming tool to enhance your design...
Trade offs/Tech choices
Explain any trade offs you have made and why you made certain tech choices...
Failure scenarios/bottlenecks
Try to discuss as many failure scenarios/bottlenecks as possible.
Future improvements
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?