Twitter Social Network – System Design Interview Preparation
Practice designing Twitter. Cover tweet posting, timeline generation, fan-out, trending topics, and real-time notifications.
This is a full mock interview round, not a written solution to read through. The AI interviewer poses the Twitter design problem, pushes back on your choices, and asks the follow-up questions a real interviewer would: how the system behaves as traffic grows, where the bottlenecks move, which consistency guarantees you are trading away, and what happens when a component fails. You get structured feedback and a score on requirement gathering, high level architecture, data modelling, scalability and communication at the end of every attempt.
Designing Twitter is a recurring question in High Level Design (HLD) rounds at Google, Amazon, Meta, Microsoft, Netflix and Uber, and at high-growth product companies hiring SDE-2 and above. Working through it out loud - repeatedly, under time pressure - is what separates candidates who know the components from candidates who can defend a design.
What this question is really testing
Fan-out on write versus fan-out on read, and the fact that neither works alone once one account has 100 million followers.
Scale to establish before drawing anything
- 300M monthly users, 150M daily; 500M tweets a day is about 6,000 writes a second, with peaks far higher.
- Timeline reads are 100x writes - roughly 600,000 a second - and must return in under 200ms.
- A tweet is around 300 bytes; a timeline of 800 entries per user is manageable in a cache, the full history is not.
Core components
- Tweet service – Write path. Persists the tweet and emits an event.
- Fan-out service – Pushes a tweet id into each follower's timeline cache. Asynchronous, and the thing that falls over on celebrity accounts.
- Timeline cache – A capped, ordered list of tweet ids per user. Reads hit this, not the database.
- Social graph store – Followers and following. Read on every fan-out, so it is heavily cached.
- Hydration service – Turns tweet ids into tweet bodies plus author and engagement counts, at read time.
Trade-offs to defend
- Hybrid fan-out – Push for normal accounts, pull for accounts above a follower threshold, merged at read time. This is the answer the question is looking for, and the threshold is the part to defend.
- Eventual consistency on the timeline – A follower seeing a tweet seconds late is acceptable; the alternative is synchronous fan-out to millions.
- Chronological versus ranked – Ranking turns a cheap list read into a scoring problem and changes the cache from a list to a candidate set.
Follow-up questions to expect
- An account with 100M followers tweets. Walk through what happens in the next 60 seconds.
- A user follows 5,000 accounts and opens the app after a week. Where does their timeline come from?
- A tweet is deleted after fan-out. How does it leave 100,000 timelines?
Continue preparing