← All comparisons

Twitter Home Timeline vs URL Shortener

Twitter Home Timeline

Twitter Home Timeline

Hybrid fan-out: push for most users, pull for celebrities, merged at read time.

Components (9)

  • Client
  • API Gateway
  • Timeline Service
  • Tweet Service
  • Kafka
  • Fan-out Worker
  • Redis
  • Tweet Store
  • Celebrity Tweet Cache

Headline numbers

  • Tweets / sec~870/sec avg, ~6,000 peak
  • Timeline read QPS~43,500/sec
  • Fan-out writes / sec (non-celebs)~87,000/sec
URL Shortener

URL Shortener

Hashing, key generation, read-heavy caching.

Components (6)

  • Client
  • API Gateway
  • Write Service
  • Read Service
  • Redis
  • Postgres

Headline numbers

  • Write QPS (avg)~1,200/sec
  • Read QPS (avg)~120,000/sec
  • Storage per year~5 TB

Key differences

Only in Twitter Home Timeline
  • Kafka
In both
  • Client
  • Api Gateway
  • Service
  • Cache
  • Database
Only in URL Shortener
None.

Flow shape

Twitter Home Timeline flows
  • Normal user posts a tweet (fan-out on write)6 steps
  • Celebrity posts a tweet (skip fan-out)4 steps
  • Open home timeline (hybrid read)5 steps
  • Fan-out Worker is down6 steps
  • Celebrity cache cold-start5 steps
URL Shortener flows
  • Shorten a URL3 steps
  • Resolve short URL (cache hit)3 steps
  • Resolve short URL (cache miss)4 steps
  • Redis is down4 steps