System Design: News Feed (Walnut Feed: 500M Daily Users, Hybrid Fan-out, Two-Stage Ranking)
We design a news feed for a large social app. Our version is called Walnut Feed.
A user opens the app and sees a ranked list of posts from the accounts they follow. A new post must reach followers within seconds, and the feed must load even when parts of the system are down.
As in any system design interview, every number here is our own planning assumption, and the design is our own. All times are Chicago time.
How to read this post. It takes about 55 minutes in full, so it is built to be read in parts:
1. Requirements
1.1 What we are building
Walnut Feed has 1 billion accounts, and 500 million open the app on a normal day. It does three jobs:
- It delivers. When someone posts, the post reaches the feeds of their followers within seconds.
- It ranks. When someone opens the app, it picks and orders the posts most worth showing, in under 50 ms at the median.
- It keeps loading. If a store fails, the user still gets a feed. It is a simpler one, such as recent posts from the big accounts they follow plus popular posts.
The story takes place on Thursday 15 October 2026:
- 19:02:00. Lucy is a nurse in Chicago with 300 followers. She posts a photo from her hospital's charity run. Within a second, the post is in the feed list of every follower who opened the app this week.
- 19:05:00. Ava Stone is a singer with 50 million followers. She posts that her tour starts in Chicago. Her post is not copied into 50 million lists. Every feed server already holds it in memory.
- 19:06:10. Noah, who follows Lucy and Ava and 198 other accounts, opens the app. His first page shows Lucy's photo and Ava's tour post, ranked with 18 others.
- 19:06 to 19:08. Noah scrolls three pages, 20 posts each. No post appears twice, even though new posts arrive while he scrolls.
- 19:20. Noah blocks an account that keeps posting ads. Its posts are gone from his very next page.
- 21:30. Kafka, the event log between the post service and the workers, is down for 10 minutes. Posting still works. Posts reach followers late, about 13 minutes at worst, and none of them is lost.
- Friday 08:10. Grace opens the app after five weeks away. She has no feed in memory. She sees an interim feed at once, and her real feed is rebuilt for her next refresh.
The hard part is the follower count. Lucy's post means 300 small writes, but Ava's would mean 50 million. And readers ask 116,000 times a second at peak, so reading must stay cheap.
1.2 Words we use
Words used in only one place are explained there. Each word below is used all through the post.
Feeds and posts
| Word | Meaning |
|---|---|
| Feed list | One user's list of post IDs that were pushed to them and not shown yet, newest first. At most 400 entries, kept in memory. |
| Fan-out | Copying one post's ID into many followers' feed lists. A delivery is one copy into one list. |
| Push, pull | Push does the work when a post is written: it delivers the post to every follower. Pull does it when a feed is read: it fetches recent posts from each account the reader follows. |
| Big account | An account with 10,000 followers or more, such as Ava. Its posts are pulled, not pushed. Every other account is a normal account. |
| Session | The ranked order of 60 posts, saved for 10 minutes. The three pages a user scrolls come from it. |
| Seen list | The last 200 posts shown to one user, so no later session shows them again. |
| Interim feed | A quick feed of posts from the big accounts a user follows, plus popular posts. It is shown while a real feed is rebuilt. |
Ranking
| Word | Meaning |
|---|---|
| Candidate | A post that could go into this user's feed right now. |
| Stage 1 | A quick score that cuts hundreds of candidates to 60, using only data already in memory. |
| Stage 2 | A model that estimates how likely this user is to react to each of the 60, and orders them. |
| Affinity | How close a user is to an author, from how often the user reacts to that author's posts. |
Changes that must not be lost
| Word | Meaning |
|---|---|
| Outbox | A small table in the post database. A new post and its "to send" row are saved in one transaction, and a relay sends the row on. |
| Kafka topic | Kafka is a log that keeps messages in order until readers take them. A topic is one named stream, such as posts. |
Servers and storage
| Word | Meaning |
|---|---|
| Valkey | An in-memory key-value store, an open-source fork of Redis. Reads and writes take microseconds, and data in memory can be lost if a server dies. |
| Shard | One slice of a store, kept on its own server, with a copy on another server. |
| Round trip | One request over the network and its reply. Each has a fixed cost, so sending many commands in one round trip is cheaper. |
| Region, data center | A region is one area of the world where we run servers, such as US Central. It has three data centers, a few kilometers apart. |
| p99 | The time that 99 of every 100 requests beat. It shows the slow cases. |
IDs in this post
Every ID below is made up for the story.
| ID | What it names | Example |
|---|---|---|
| user 42 | A user ID | Noah |
| user 7310 | A user ID | Lucy |
| user 9 | A user ID | Ava Stone, a big account |
| post 1845 | A post ID, shortened here | Lucy's photo at 19:02 |
feed:{42} | A key in the Feed cluster | Noah's feed list |
| session s-91 | A session ID | Noah's ranked 60 posts at 19:06:10 |
1.3 Every kind of request and change
The story follows a few people. Walnut Feed handles much more than that. Each row names the part that handles it.
| Kind | What it is | How big or how often | Which part handles it | Outside company that takes part |
|---|---|---|---|---|
| Feed read | A page of 20 ranked posts. Noah's at 19:06:10 is one | 116,000 a second at peak | Feed servers, the Feed cluster and the Post cluster | None |
| New post | Text, with links to photos or video. Lucy's photo is one | 1,750 a second at peak | The Post service and the Post database | A CDN serves the photos |
| Delivery | One post ID into one follower's feed list | 12.45 billion a day | Fan-out workers and the Feed cluster | None |
| Big-account post | A post from an account with 10,000 followers or more. Ava's is one | 250,000 a day | Every Feed server, from the Big posts log | None |
| Follow, unfollow | One account starts or stops following another | Millions a day | The Graph service and the Graph store | None |
| Mute, block, hide | Stop seeing an author or a post. Noah's block is one | A small share of actions | The Graph service, then the Feed cluster | None |
| Delete a post | The author removes their own post | A small share of posts | The Post service, then a marker in the Post cluster | None |
| Rebuild | A new feed, built for a user who has none in memory. Grace's is one | Up to 2,000 a second in each region | Feed servers, the Graph store and the Post cluster | None |
| Counts | Like, comment and share totals for each post | Updated every second | The Counter service, another team's, into the Post cluster | None |
This post follows Lucy's post, Ava's post and Noah's feed in depth. The other kinds use the same parts.
1.4 Functional requirements
- Feed. Show a ranked feed of posts from the accounts a user follows.
- Post. Create a post: text, with links to photos and video.
- Scroll. Page through the feed with no repeated and no skipped posts.
- Follow. Follow and unfollow an account.
- Own posts. A user always sees their own new post at once.
- Mute and block. Posts from an unfollowed, muted or blocked account stop showing.
- Delete. A deleted post stops showing.
- Refresh. Pull to refresh shows new posts.
- No repeats. Do not show a post the user has already seen.
- Hide. Hide one post, and use that as a signal for ranking.
Out of scope:
- storing photos and video, which a CDN serves;
- likes and comments themselves, which other services own;
- search and ads;
- posts from accounts the user does not follow, except as fillers when the feed runs short.
1.5 Non-functional requirements
- Fast. A feed page takes under 50 ms at the median and under 200 ms at p99, measured at the server.
- Big. 116,000 feed reads and 1,750 new posts a second at peak.
- Fresh. A normal account's post reaches followers' feed lists within 5 seconds at p99.
- Always a feed. 99.99% of feed requests get a feed. It may be a simpler one, such as popular posts.
- Posts kept. A post that the author was told is saved survives the loss of a data center.
- Feed lists may be lost. Feed lists, seen lists and sessions can be rebuilt from posts and the follow graph.
1.6 The numbers
These are rough sums, the kind a candidate does at a whiteboard in a few minutes.
| Number | How we get it | Result | What it decides |
|---|---|---|---|
| Feed reads | 5 billion a day รท 86,400 seconds = 58,000 a second. The peak is twice the average | 116,000 a second at peak | Reading must be cheap, so work moves to the moment a post is written |
| New posts | 50 million a day รท 86,400 = 580 a second. Posting is burstier: three times at peak | 1,750 a second at peak | Writes are few. A post can afford a transaction in a SQL database |
| Pull only | 116,000 reads ร 200 followed accounts each | 23 million author lookups a second | Building every feed at read time is far too much work |
| Push only | 50 million posts ร their followers, from the table in the fan-out deep dive | 80 billion deliveries a day | One post from a 50-million-follower account is 50 million writes. Big accounts must not be pushed |
| Hybrid | Push only for accounts under 10,000 followers: 12.45 billion deliveries a day รท 86,400 | 144,000 deliveries a second | 85% of the push work goes away. Big accounts are pulled |
| Big-account posts | 0.5% of 50 million posts a day are from big accounts: 250,000 a day. A day of them, with their data | About 300 MB | They fit in every Feed server's memory, so pulling them needs no network call |
| Feed memory | 700 million users opened the app in the last 7 days ร about 4.2 KB of keys each | 2.9 TB | Feed lists live in memory, split over 128 shards of about 23 GB. Memory, not CPU, sets the shard count |
| Post fetches | A new session (40% of reads) fetches 60 posts and a next page fetches 20, so 36 a read on average. 116,000 ร 36 ร 40% not already in Feed server memory | 1.7 million a second | Round trips, not memory, limit the Post cluster. Fetch only the 60 posts worth ranking closely |
What these numbers tell us: reads outnumber posts 66 to 1, so most work happens when a post is written. But pushing a few huge accounts would cost more than everything else together, so their posts are pulled from memory instead.