SD-6 · System design
Design a Microblog Timeline
Asked at Mid level45 minutes
Our answers stay hidden until you reveal them.
Question
Our solution
Design a microblogging service. People post short text messages, called tweets here, follow other accounts, and read a home timeline: the newest tweets from everyone they follow. They can also open a profile, like and repost, and search recent tweets.
The service has 250 million daily users who load a timeline page about 35 times a day, and 430 million tweets are posted a day. Reads beat writes 20 to 1, and timelines must load in well under a second. The hard part is the follow graph: the average account has 200 followers, but a few have over 100 million, so “show every follower this tweet” is cheap for almost everyone and ruinous for a handful.
Good questions to ask first
Decide what you would assume for each before you look at ours.
- 1How long is a tweet?
- 2How is the home timeline ordered?
- 3How fresh must it be?
- 4How far back can you scroll?
- 5How big do accounts get?
- 6Can tweets be edited or deleted?
- 7Do we need reposts and likes?
- 8Is search in scope?
How to spend the 45 minutes
- 5minPart 1: Requirements and scope
- 5minPart 2: Estimates
- 5minPart 3: API
- 15minPart 4: Architecture, stage by stage
- 15minPart 5: Deep dives: fan-out, IDs, caches
Sketch your own design: boxes, arrows and the numbers that matter. Then compare it with ours.Break it in the labVisual walkthrough