Phase 1: Clarify, Scope & Constraints
Interviewer: "Let's design Twitter — specifically the home timeline and trending topics features. How do you approach this?"
Candidate: "Good. Let me identify the user journeys I'll focus on:
- Tweet journey — User posts a tweet (text, optionally with media); it appears in their followers' timelines
- Timeline journey — User opens the app and sees a ranked home timeline of tweets from accounts they follow
- Trending journey — User sees a list of trending topics/hashtags in real time, filtered by location
- Search journey — User searches for tweets matching a keyword, seeing real-time results
The dominant complexity is the timeline delivery problem — specifically the write amplification challenge. Twitter has ~245M DAU and some users (Elon Musk, Barack Obama) have tens of millions of followers. A single tweet to 100M followers naive fan-out means 100M write operations. At 500M tweets/day that's potentially trillions of timeline writes — you cannot push everything synchronously.
WHY: The secondary complexity is trending topics — computing what's trending requires real-time stream processing of tweet velocity, not just volume. A topic trending since 2020 shouldn't outrank something that just went viral in the last 5 minutes. This is a sliding window velocity problem, not a simple count.
Non-goals for V1:
- Twitter Spaces (audio rooms)
- Twitter/X Premium features (long-form posts, priority ranking)
- Direct Messages
- Ads serving and monetization
- Twitter API / developer platform
Interviewer: "What about the 'For You' algorithm-based timeline vs. the 'Following' chronological timeline? Both exist now."
Candidate: "Great distinction. I'll design…
In the full tutorial
- Phase 2: High-Level Architecture
- Phase 3: Deep Dive & Evolution
- Phase 4: Robustness & Operations