SYSTEM DESIGN SKETCHBOOK / PRACTICE SHEET / NO. 06
Design a microblog home timeline
People post short text updates and follow whoever they like. Opening the app shows a home timeline: the newest posts from everyone you follow. Most accounts have a few dozen followers, but a handful of public figures have more followers than most countries have people.
Requirements
- Publish a post of up to 280 characters.
- Follow and unfollow any account without approval.
- Show a home timeline of posts from followed accounts, newest first, with pagination.
- Show a user timeline of one account's own posts.
Constraints and assumptions
- 250 million daily active users and 500 million new posts a day (about 6,000 per second, peaking at 20,000).
- Home timeline reads peak at 300,000 per second; p99 under 200 ms.
- The average account has 200 followers, the median about 50, and the largest has 150 million.
- A post from an ordinary account should appear in followers' timelines within 5 seconds.
- A home timeline shows at most the most recent 800 posts; older posts are reachable only through user timelines.
Out of scope for the first sketch
Ranking or recommendations (strictly reverse-chronological) · Search, trends and hashtags · Media attachments and direct messages
Draw your design
Rough math and notes
SYSTEM DESIGN SKETCHBOOK / FOLLOW-UPS
Design a microblog home timeline
Finish your first sketch before answering these. Cross out freely.
- Walk through what happens when the account with 150 million followers posts. How many writes is that, and how long until the last follower can see it?
- Many users have not opened the app in a month. Is it worth keeping their timelines up to date?
- A user follows a new account. When do that account's earlier posts show up in the home timeline?
- A post is removed for abuse two minutes after it was delivered. How does it disappear from millions of timelines?
- Where exactly do you draw the line between accounts you push and accounts you pull, and what happens when an account crosses it?
Compare afterwards: worked approaches and reading at sketchbook /questions/microblog-timeline/review