LESSON 04 · Distribution strategy

Choose where fanout happens

Push common posts to inboxes, pull very large audiences at read time, and mix both when needed.

SYSTEM VIEW

The feed path

Diagram view
Large author push—
Unread—
Merging—

Watch posts get pushed into inboxes and a large author’s posts get pulled instead, then see a hybrid merge both at read time.

  1. Fanout on write: the Ordinary author publishes post 4430, and Fanout workers add its ID to each of the 200 followers’ inboxes. When the Reader opens the feed, the candidate list is already there, so the read is cheap.

    Followers
    200
    Writes
    200 per post
    At read time
    list ready

    What changed

    • Post 4430 published
    • 4430 in 200 inboxes
    • Reader’s candidates ready
  2. The Large author has 2 million followers and posts 10 times a day, so pushing post 4520 alone means 2 million inbox writes, 20 million a day. Only 5% of followers open the app today, so 19 million go to people who don’t look.

    Writes
    2M × 10 = 20M a day
    Open the app
    5% today
    Unread
    19M writes a day

    What changed

    • Post 4520: 2M inbox writes
    • 20M inbox writes a day
    • 19M of them unread
  3. Fanout on read: the Large author’s post 4521 goes only into the Author index, with no inbox writes. Instead, each of the 100,000 active readers fetches and merges that author’s posts on every feed load, which adds read latency and merge cost.

    Inbox writes
    none
    Active readers
    100,000 (5% of 2M)
    Every load
    fetch + merge

    What changed

    • Author index
    • 20M inbox writes a day
    • 100,000 readers merge on load
  4. A hybrid pushes ordinary authors into inboxes and keeps very large authors in the Author index; the Feed service merges both when the Reader loads the feed. That is two read paths to test, so a network without extreme accounts can stay with push alone.

    Pushed
    ordinary authors
    Pulled
    very large authors
    Described by
    Twitter engineers

    What changed

    • Ordinary authors from Inboxes
    • Largest authors from the index
    • One merged feed
  5. The threshold is measured: one million inactive followers differ from one million readers refreshing now, and the Large author’s 2 million followers include 100,000 active readers. Weigh publish rate, fanout lag and read latency too, and bound push work with partitions, per-author limits and backpressure.

    Active readers
    100,000 of 2M
    Also weigh
    publish rate, lag, latency
    Bound with
    queue partitions, limits

    What changed

    • Threshold from active readers
    • Per-author limits
    • Backpressure
  6. The Large author has moved from push to pull, so post 4520 is in pushed inboxes and the Author index. A transition rule keeps posts neither missing nor doubled: Dedupe by post ID shows 4520 once; No dedupe shows it twice.

    Pushed earlier
    4520
    In the index
    4520, 4521

    What changed

    • Large author: push → pull
    • 4520 in both sources
    • Transition rule needed
    Merge rule

Space plays · ← → step · Home resets

THE IDEA

How it works

Fanout on write adds a post ID to each eligible follower’s timeline as the author publishes. Reads become cheap because the candidate list is ready, but a high-follower author creates many writes and inactive followers consume needless work. Fanout on read queries followed authors’ recent posts when a reader opens the feed, reducing idle writes but increasing read latency and merge cost.

As an example, an author with 2 million followers posts 10 times a day, and 5% of followers open the app that day. Pushing costs 20 million inbox writes, of which 19 million go to people who do not look today. Pulling costs no writes, but each of the 100,000 active readers must fetch and merge that author’s posts on every feed load.

A hybrid pushes ordinary authors to follower inboxes and leaves very large authors in their own recent-post indexes. At read time the feed service merges the reader’s inbox with recent posts from those high-follower authors. Twitter engineers have publicly described this kind of design. The threshold is a measured choice based on follower count, active-reader fraction, publish rate, fanout lag, and read latency. A hybrid also means two read paths to test, so a network without extreme accounts can stay with push alone.

Avoid treating a follower count as a complete cost estimate. One million inactive followers differ from one million readers refreshing now. Bound work with queue partitions, per-author limits, and backpressure. Changing an author between push and pull needs a transition rule so posts are neither absent nor shown twice.

DECISION POINT

A musician with 20 million followers publishes twice a day. Most followers open the app weekly. Which fanout choice deserves testing?

Write a sentence or two to unlock the guidance. Committing first is what makes it stick.

Keep in mind

  • Write fanout trades extra writes for fast reads; read fanout does the reverse.
  • Hybrid fanout handles skew and must define deduplication during strategy changes.
CHECK YOUR UNDERSTANDING

Put it into practice.

1 OF 3
RecallQUESTION 01

What does fanout on write buy?

Choose an answer. You’ll see the explanation once you get it right.

Next lesson

0 of 3 checkpoints answered correctly to complete this lesson.