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.

2 min read·8 sections
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.

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

  • The celebrity problem is a write-amplification problem.
  • Timeline cache stores IDs, not full post blobs.
  • Backfill and ranking must tolerate partial freshness.

Common trap

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

Common questions

What problem does Design a news feed (Twitter) solve?

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

How does Design a news feed (Twitter) work?

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.

What are the tradeoffs of Design a news feed (Twitter)?

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

Where is Design a news feed (Twitter) used in production?

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

Part of Academy on SystemLore — system design explained with 148 deep topics, interactive diagrams, and a build-it-yourself game. Browse the glossary and "X vs Y" comparisons, or build this one →