# Social news feed - fan-out on write or on read

> Fan-out on write against fan-out on read, and when each loses. Fan-out on write is drawn as the default and it breaks on the celebrity: one publish by an…

Source: https://tierslate.com/templates/news-feed

Social & feeds · System design · core · 8 step walkthrough · 3 tables

Fan-out on write against fan-out on read, and when each loses.

**Own this board: 400 credits.** The first act plays on the page. Owned once with credits, never a subscription.

## What this board gets wrong on purpose

The tension: Fan-out on write is drawn as the default and it breaks on the celebrity: one publish by an account with ten million followers becomes ten million writes, and while the workers chew through that single post every ordinary post is stuck behind it. The threshold on the fork is a hardcoded number nobody can defend, and the board does not say what happens to an account that crosses it between one post and the next.

## Practise this as an interview

Take Social news feed - fan-out on write or on read as a timed system design interview on a blank board - on your own, with the requirements to check yourself against, or with a candidate you invite.

## Start here

### Why this design

The news feed is the canonical read-amplification versus write-amplification question, and it is asked at every company that has a timeline because the answer is not a component, it is a trade. Interviewers use it to see whether you notice that follower counts are heavy-tailed - most authors have a few hundred followers and a handful have tens of millions - and whether you can size a cache from first principles. Real feed teams live inside the hybrid this board draws, and spend their time on the threshold between its two halves.

### What you will learn

- Why fan-out on write makes a feed open one cache read, and why it turns a 10M-follower publish into 10M writes and roughly 13 seconds of the entire fan-out fleet.
- Why authors over 10k followers are 6% of posts but would be 93% of fan-out writes, and why the hybrid pulls exactly those at read time instead.
- How to size the feed cache: 500 ids x 24 B for 600M monthly actives is 7.2 TB of RAM, and why it holds ids, not posts.
- Why the read path merges two architectures - a precomputed list and about six pulled author lists - and what the ranker has to dedupe.
- What happens when an account crosses the threshold between two posts, and why the threshold belongs in a per-account column with hysteresis rather than in code.
- Why each region fans out locally from a replicated event stream rather than replicating 22.6 billion feed writes a day.

### How to read this board

1. Diagram, top to bottom: PUBLISH (one write, one event), then THE FOLLOW GRAPH beside the FAN-OUT DECISION - the diamond is the whole template.
2. Then the two answers side by side: FAN-OUT ON WRITE (workers and the feed cache) and FAN-OUT ON READ (one store and a decision not to act), then SERVING, where they merge. Press Play for the eight-step walkthrough of one post.
3. Page 1 · Requirements - the questions that decide push or pull before anything is drawn.
4. Pages 2 and 3 · Capacity and Storage - the celebrity arithmetic, and why the feed cache is the big number.
5. Page 4 · Availability - what degrades, and the failure that hides a post rather than erroring.
6. Page 5 · How it works - one post end to end, then Page 6 · Deployment, including how to change the threshold safely.
7. Finally the DATA MODEL at the bottom: three tables, and the feed is not one of them.
8. The conversation to have: the "10k" on the diamond is a hardcoded number nobody can defend, and the board does not say what happens to an account that crosses it.

## 1 · Requirements

### Ask these before drawing anything

- What is the follower distribution? Not the mean - the tail. If the largest account has 5,000 followers, pure push is correct and this board is over-built. If it has 10 million, pure push is an outage.
- Is the feed reverse-chronological or ranked? Ranked means the candidate set is bigger than the page and somebody scores it; chronological means the merge is the whole job.
- How fresh must it be? "A follower sees the post within five seconds" sizes the fan-out fleet. "Within a minute" lets it run at average load rather than peak.
- How deep does a feed go? People scroll a few hundred items, not a year. The answer bounds every per-user list on this board.
- Does an inactive user need a feed at all? Building timelines for people who have not opened the app in a month is most of the write cost and none of the value.
- Does delete, block or unfollow have to take effect instantly in feeds that were already built? It decides whether those are filtered at read time or chased through the cache.
- What happens to an account whose follower count crosses the threshold? This is the question the board leaves open on purpose.

### Functional

- Publish a post (text plus a media reference) and have it appear in every follower’s home feed.
- Follow and unfollow; the next feed open reflects the change.
- Open the home feed: a page of 50 ranked posts, then further pages by cursor.
- Delete a post and have it vanish from every feed, including ones already built.

### Non-functional

- Feed open: p99 under 200 ms server-side at 104,000 opens/s peak.
- Publish: acknowledged once the post store has it, p99 under 300 ms. Fan-out is asynchronous and is never on this path.
- Fan-out lag for authors under the threshold: p99 under 5 s from publish to a follower’s feed cache, and under a minute even at peak.
- A celebrity’s post must not delay anybody else’s. This is the requirement pure push cannot meet.
- Posts are durable (three replicas). The feed cache is not: losing it costs latency, never data.
- Feeds are eventually consistent. Two devices may briefly show different feeds and nobody minds.

### Out of scope

- The media pipeline and CDN, search, notifications and ads.
- Recommended posts from accounts the reader does not follow - a different candidate source feeding the same ranker.
- Ranking model training. This board treats the ranker as a service that scores candidates.

## The rest of this board

This page publishes the question. The answer - 5 more written pages, an 8-step narrated walkthrough and a 3-table schema - is the board itself, and it opens in Tierslate.

- 5 written pages
- 8 walkthrough steps
- 3 tables (15 columns)

5 pages behind this one:

- Capacity estimation
- Storage estimation
- Availability
- How it works
- Deployment plan

## Related system design templates

- [Media feed system design](https://tierslate.com/templates/instagram-feed) - Why the feed serves URLs and the edge serves bytes, and who actually pays for the pixels.
- [The professional graph system design](https://tierslate.com/templates/linkedin-connections) - Why a degree badge on every name is a graph held in memory and searched from both ends, not a join.
- [Comment trees system design](https://tierslate.com/templates/reddit-comments) - How a whole comment tree comes back in one range scan, and why every vote rewrites what it cached.
- [The social graph system design](https://tierslate.com/templates/social-graph) - Why every follow is written twice on two shards with no transaction between, and what that drift costs.
- [Home timeline system design](https://tierslate.com/templates/twitter-timeline) - Why one post is fanned out into hundreds of precomputed timelines, and why the celebrity cannot be.
- [Blog platform system design](https://tierslate.com/templates/blog-platform) - Why a blog is a read-heavy system where the cache is the product, and what publishing has to invalidate.
- [Link previews system design](https://tierslate.com/templates/link-preview) - Why unfurling a pasted URL is a server-side request forgery problem first and a caching problem second.
- [Reviews and ratings system design](https://tierslate.com/templates/reviews-ratings) - Why a star rating is an aggregate maintained on write, and how fake reviews are held back before they count.
- [Content moderation system design](https://tierslate.com/templates/content-moderation) - Why moderation is a fast automatic gate plus a slow human queue, and what is shown while it decides.
- [Stories system design](https://tierslate.com/templates/ephemeral-stories) - Why expiry is a read-time filter plus a background sweep, and why the viewer list is the expensive part.

All 100 system design templates: https://tierslate.com/templates (Markdown: https://tierslate.com/templates.md)
