Design Twitter Timeline

Hard45 min
1 / 30
understanding10 min read

Problem Statement: A Read-Amplified Fan-Out System

Frames the timeline as a fan-out problem where one write becomes millions of reads and millions of cache writes, and separates ingestion, fan-out, ranking, and delivery planes.

Problem statement

Design the core of a microblogging platform: users publish short posts in real time, and every follower expects those posts to appear in a personalized home timeline within seconds. The system must support hashtags, mentions, retweets and quote-posts, deliver notifications for mentions and follows, and serve two timeline modes: a chronological Following feed and a ranked For You feed. The defining asymmetry is that one post can fan out to millions of followers while each reader expects a sub-second, pre-assembled feed. This is a write-amplification problem dressed as a read-latency problem.

Public figures anchor the category. Twitter reported 217 million monetizable DAU in Q4 2021 and 237.8 million in its last reported quarter [[1]][[6]]. Public estimates put X at roughly 500 million posts per day, about 6,000 per second on average [[12]][[13]]. Twitter's own infrastructure writing describes timeline delivery as a primary cache workload driven by high-fanout microservices [[25]], and its early Fanout service queried a Flock-based social graph across multiple hash rings [[24]]. The well-documented production pattern is hybrid: fan-out on write for ordinary authors, fan-out on read for celebrities [[26]].

Why this problem is distinctive

A chat system fans in: many writers, one reader per message. A timeline fans out: one writer, potentially tens of millions of readers. Naive push copies every tweet into every follower's inbox and collapses under celebrity writes. Naive pull merges hundreds of followed lists at read time and collapses under read QPS. The entire design is the search for a hybrid boundary between the two, plus a ranking layer that turns a merged candidate pool into a relevant feed, plus a notification layer that must not double-deliver.

The four architectural planes

  1. Ingestion plane: validation, tweet persistence, snowflake ID assignment, event publication.
  2. Fan-out plane: social graph lookup, push to follower timeline caches, deferred pull for celebrity edges, notification dispatch.
  3. Ranking plane: candidate sourcing, feature hydration, scoring, visibility filters, diversity heuristics.
  4. Delivery plane: timeline cache reads, hydration of tweet objects and counters, cursor pagination, WebSocket and push notification delivery.

Public baseline versus design assumptions

Cited numbers above are company-reported or public estimates, not requirements for our design. For capacity planning this answer explicitly assumes: 400 million DAU, 500 million tweets per day, 150 billion follow edges, an average of 700 followers per posting author with a heavy celebrity tail, 30 percent of followers active on a given day, and a 5x peak multiplier for global events. Every uncited number in this answer is a stated assumption, budget, or target.

Key Highlights

  • One write fans out to millions of follower caches; one read merges hundreds of author lists. The design is the boundary between push and pull.
  • Twitter reported 217M mDAU in Q4 2021 and public estimates put X at ~500M posts/day (~6K/s average).
  • Production precedent is hybrid fan-out: push for ordinary authors, pull-at-read for celebrities.
  • Four planes: ingestion, fan-out, ranking, delivery. Each has a different consistency and latency contract.
  • All uncited scale numbers in this answer are explicit design assumptions.
Lead With the Fan-Out Asymmetry
State in the first two minutes: one tweet can become millions of cache writes, and one read can merge hundreds of lists. Naming write amplification versus read latency immediately separates a feed architect from a CRUD developer.
Do Not Draw Pure Push or Pure Pull
Pure push collapses under a celebrity posting to 100M followers; pure pull collapses when 400M readers each merge 500 author lists. A credible answer is hybrid from the first diagram.

Section Rescue Kit

Buzzwords to use:

Fan-Out On WriteFan-Out On Read

Safe statements:

  • "Let me separate the write path, which amplifies, from the read path, which must stay under one round trip."
  • "Before choosing push or pull, I need the follower distribution, because the celebrity tail decides everything."
Design Twitter Timeline - System Design | WinJob | WinJob