Design Twitter
Social NetworkHard
Design a simplified version of Twitter where users can post tweets, follow other users, and see a timeline of tweets from users they follow.
Requirements
- Users should be able to post short messages (tweets) of up to 280 characters.
- Users can follow other users to see their tweets.
- The home timeline should show tweets from followed users, sorted by recency.
- Users should be able to like and retweet other tweets.
- The system should support basic search functionality.
- Users should receive notifications for interactions with their tweets.
Constraints
- The system should handle high read/write volumes (millions of tweets per day).
- Timelines should load quickly, even for users following thousands of accounts.
- Tweets should be delivered to followers with low latency.
- The system should be highly available and resilient to failures.
Example Scenarios
A user posts a new tweet that needs to be delivered to their millions of followers.
Key Considerations:
- How will you handle the fan-out of tweets to followers?
- Will you push to followers' timelines at write time or pull at read time?
- How will you handle users with very large follower counts (celebrities)?
- How will you optimize storage and retrieval of tweets?
A user searches for tweets containing specific keywords or hashtags.
Key Considerations:
- How will you index tweets for efficient search?
- How will you handle trending topics?
- Will you support advanced search operators?
- How will search results be ranked?
Your Solution
Submission Guidelines
- • Include a high-level architecture diagram
- • Define system components and their interactions
- • Address scaling and reliability concerns
- • Explain trade-offs in your design decisions
- • Consider failure scenarios and how to handle them