Academy · Real-World System Designs

Design a news feed (Twitter)

Deliver each of 300M users a timeline of recent posts from everyone they follow, instantly — including celebrities with 100M followers.

Open the interactive version → diagrams, practice & more

The problem

Deliver each of 300M users a timeline of recent posts from everyone they follow, instantly — including celebrities with 100M followers.

The idea

Precompute timelines via fan-out, with a hybrid approach for celebrities.

How it works

On a new post, fan-out-on-write pushes it into followers' cached timelines (fast reads). For mega-accounts that's too expensive, so fan-out-on-read pulls their posts at view time (hybrid). Tweets/graph in NoSQL, timelines in cache, media in object store + CDN, search alongside.

The tradeoff

Fan-out-on-write = fast reads, expensive writes; fan-out-on-read = cheap writes, slow reads. The hybrid balances both.

In the wild

Twitter's timeline architecture is the canonical example of this tradeoff.

Interview deep dive

Flow

  1. User posts; write tweet to durable storage.
  2. Fan-out worker pushes tweet IDs into normal followers' timelines.
  3. Celebrity posts stay in author storage and merge on read.
  4. Timeline read hydrates IDs, ranks, and fetches media through CDN.

Watch for

Interviewer trap

State the hybrid threshold and what metric would make you change it.

Related Academy

Part of Academy on SystemLore — system design interview prep with 148 deep topics, interactive diagrams, and a practice game. Practice this one →