A home timeline at 300,000 reads a second
Design a News Feed (Twitter Timeline), from a blank page
This is how the interview actually runs: one prompt, and you decide what to cover and in what order. Write each section, then compare it with a reference design and see what you left out.
A 45-minute round. You drive; nothing prompts you.
The prompt
On a social network, people post short messages and follow other accounts. The home timeline shows the latest posts from everyone you follow, newest first, and it is the first thing every app open loads.
At the scale Twitter described in 2012–13: about 150 million active users, around 400 million posts a day (roughly 5,000 a second, 12,000 or more during big live events), and about 300,000 home-timeline reads a second. Most accounts have a few hundred followers. A handful have tens of millions.
Raffi Krikorian, then running Twitter's timeline infrastructure, described how they built this in his talk "Timelines at Scale".
What the interviewer would tell you if you asked
- About 300,000 timeline reads a second at peak.
- About 5,000 posts a second on average, 12,000+ during big events.
- Some accounts have more than 30 million followers.
- Posts are stored durably in a sharded database; the social graph is a separate service.
- People mostly read the first page or two of their timeline.
- Keeping the latest 800 entries per user is enough; older pages can be slower.
- Post IDs are time-sortable 64-bit IDs, so sorting by ID is sorting by time.
01
about 5 minWhat does the system have to do, and how well? List the functional requirements, then the non-functional ones (latency, availability, consistency, scale), and the questions you would ask the interviewer.
02
about 5 minTurn the volumes into the numbers that drive the design: requests per second at peak, storage, bandwidth, and anything else that decides whether one machine is enough.
03
about 10 minName the components and what each one is responsible for. Then trace the main request through them, and say where the durable state lives.
04
about 15 minPick the hardest decisions in this design and make them: what you chose, what you rejected, and which constraint decided it.
05
about 10 minWhat breaks? Walk through crashes, duplicates, slow dependencies and overload, and what the design does in each. Then: what changes at ten times the load, or with a new requirement?
Write something in at least 3 sections first. Gaps are fine; the comparison shows what they cost.