Skip to content

Scenario: news feed

Pay for a feed when posting, except for the few huge accounts, which every reader merges in at read time.

Predict first

Before you read: predict

On this lesson's feed model, a chat app's status feed could be built with fan-out on write or with fan-out on read. A broadcast channel with 2,400,000 followers posts one status, and Lina, who follows 300 accounts that have posted 3,000,000 statuses between them, then opens her feed once.

Counting each write into a feed list, each read of one, and each query for one account's statuses as one store operation (storing the status itself is not counted), which design makes fewer operations for these two events, and how many?

Pick one

The 30-second version

Precompute feeds: posting writes the status's id into each follower's list, one write per follower, so opening a feed reads one list instead of querying every account it follows. Accounts with millions of followers are flagged and merged in at read time instead. Page every source with one cursor.

Pay for a feed when posting, except for the few huge accounts, which every reader merges in at read time.

How it works

Step 1 of 10

Numbers first. Statuses posted a day, feed opens a day, followers per account (typical and largest), accounts each reader follows.

Analogy: A corner newsagent's reserved-papers shelf

At the newsagent In the design
at dawn the owner slips each title into every regular's named bundle on the shelf fan-out on write (step 3)
a walk-in customer goes round the racks taking one copy of each title she reads fan-out on read (step 2)
the national daily that 900 regulars take stays in one stack by the till; the assistant adds a copy as each bundle is handed over the hybrid (step 6)
each bundle slot holds this week's issues only the trimmed list (step 4)
'carry on from Tuesday's issue' the cursor (step 9)

In real terms: pay at posting time for most accounts, pay at reading time for the few whose followers would swamp the writers.

Breaks down when: the owner puts a whole paper in each bundle, while a feed list holds only an id and the status is stored once.

Contrasting case: a family group chat of six: fan out every message, no threshold, nothing to merge.

Examples, run for real

4.1 ExamHall EXH-4710 → MR !5010: the national notice that held up class notices

ExamHall's dashboard feed fanned out every announcement on write, national ones included, through one fan-out queue (EXH-4710). MR !5010 flags the national exam board's account, as the curriculum hook has it: class announcements fan out on write, national ones are merged at read time (steps 5–6).

4.1 model: 600,000 candidates · one fan-out queue, 20,000 feed writes a second · a national notice at 09:00:00, a class notice to 30 candidates at 09:00:01
4.1 EXH-4710 every account fanned out: national notice 600,000 writes, its last at 09:00:30 · class notice in its 30 feeds at 09:00:31
4.1 MR !5010 the national board flagged: national notice 0 writes · class notice in its 30 feeds at 09:00:02 · each dashboard read: 1 list read + 1 flagged account merged

4.2 Proof domain, chat: one cursor over two sources

Kemal's list holds seven statuses from people he follows; two flagged channels he follows posted at 12:08 and 12:02. Each page holds four, and each source returns a full page older than the cursor (step 9). Channel statuses carry an asterisk.

4.2 model: list 12:09 12:07 12:06 12:04 12:03 12:01 12:00 · flagged channels 12:08* 12:02* · pages of 4 · each source returns 4 older than the cursor, the merge keeps 4
4.2 page 1: 12:09 12:08* 12:07 12:06 · next after 12:06
4.2 page 2: 12:04 12:03 12:02* 12:01 · next after 12:01
4.2 page 3: 12:00
4.2 page 4: empty · 9 of 9 shown, each once, newest first

The cursor is a status, not a count per source, so the next page starts below the last one shown whichever source it came from.

4.3 The board for "Design a news feed like LinkedIn's" (worked, not executed)

Typical question Steps that answer it Mechanism owner
"Design a news feed like LinkedIn's." 1–4, 6 this lesson; the frontend round: fsd-sc-news-feed-ui
"An account with 10 million followers posts. What does your system do?" 5–7 this lesson; queue order: sc-multi-tenant-saas
"Why cursor pagination instead of offset for a feed?" 9 offset against keyset: api-pagination-cursor-offset; the merged cursor: this lesson

Try it

Answer first, then check. Nothing is saved.

Question 1 of 6

On this lesson's feed model, a chat app's status feed is a hybrid: accounts with over 100,000 followers are flagged and merged in at read time; the rest fan out on write. Lina follows 300 accounts, 4 of them flagged. In one day the other 296 post 600 statuses between them, the 4 flagged accounts post 50, and Lina opens her feed 40 times.

Counting each write into her feed list, each read of it, and each query for one account's statuses as one store operation, how many operations does her feed cost that day?

Pick one

Question 2 of 6

On this lesson's feed model, Lina's hybrid feed builds each page with this code. feedList.olderThan reads her precomputed list and flaggedPosts.olderThan the flagged channels she follows; each returns, newest first, up to the given number of statuses older than the cursor (all of them when the cursor is undefined).

Her list holds 12 statuses from people she follows, posted one a minute from 18:59 back to 18:48; the 3 flagged channels she follows posted at 18:58:30, 18:30 and 18:10. Starting with no cursor, she asks for each next page with the reply's next until a page comes back empty.

How many of the 15 statuses has she seen?

Code for this question
async function feedPage(user, cursor) {  const people = await feedList.olderThan(user, cursor, 5);  const channels = await flaggedPosts.olderThan(user, cursor, 5);  const page = [...people, ...channels].sort(newestFirst);  return { statuses: page, next: page.at(-1) };}
Pick one

Question 3 of 6

You have proposed flagging large accounts and merging their recent statuses into each feed at read time. The interviewer asks: "An account with 8,000,000 followers posts. Where do you set the threshold?" On this lesson's feed model, the fan-out queue makes 50,000 feed writes a second. Every status must be in all its followers' feeds within 10 seconds of posting, and no feed read may merge more than 5 flagged accounts. The app's accounts have 8,000,000, 2,000,000, 300,000 or 40,000 followers, and a typical reader follows 1, 3, 12 and 50 of them respectively.

Which threshold meets both limits?

Pick one

Question 4 of 6

On this lesson's feed model, Lina's chat app runs a hybrid status feed: accounts with over 100,000 followers are merged in at read time, from their statuses of the past week; the rest fan out on write. At 10:00 she starts following Sam, who has 240 followers, and the channel Matchday, which has 2,000,000. Each of them posted 5 statuses yesterday and none since.

How many of those 10 statuses are on her next feed page, which holds up to 20?

Pick one

Question 5 of 6

On this lesson's feed model, a chat app's status feed is a hybrid: accounts with over 100,000 followers are merged in at read time; the rest fan out on write through one queue that makes 40,000 feed writes a second, in arrival order. At 20:00:00 that queue holds 1,200,000 writes, and at that moment Nora, who has 80,000 followers, posts a status.

How many seconds after she posts is her status in every one of her followers' feed lists?

Pick one

Question 6 of 6

On this lesson's feed model, a chat app's status feed is a hybrid: accounts with over 100,000 followers are merged in at read time; the rest fan out on write. Yesterday ordinary users, each with 200 followers and following 300 accounts, posted 3,000,000 statuses; creators, each with 40,000 followers and following 500, posted 50,000; channels, each with 3,000,000 followers and following 10, posted 2,000.

Averaged over the day's 86,400 seconds, how many feed writes a second did the fan-out make, to the nearest thousand?

Pick one

Go deeper

Pro tip
  1. Name the huge account yourself, with its number, before the interviewer does. Divide its followers by your fan-out's write rate, out loud: that is how long one of its statuses holds the queue, and why the hybrid exists. When: the interviewer gives a follower count. Status: RAN on the model.
Source

No item is keyed on a source; every key is executed on a model whose rules these pages state. Interview advice is valid as of 2026-10-17.

  • Hello Interview, problem breakdown: Facebook News Feed (the curriculum row's source): https://www.hellointerview.com/learn/system-design/problem-breakdowns/fb-news-feed (hello-interview-fb-news-feed.txt). "This is called fan-out on write — instead of assembling the feed when a user asks for it, we precompute feeds when posts are created." (step 3); "a list of post IDs in reverse chronological order, limited to a small number of posts (say 200 or so)" (step 4); "merge it with recent posts from those accounts which aren't precomputed." (step 6); "We can tune the threshold over which an account is ignored in precomputation." (step 7); "a timestamp of the oldest post they've looked at" (step 9).
  • System Design Primer, Design the Twitter timeline and search (the curriculum row's source, github.com/donnemartin/system-design-primer): https://raw.githubusercontent.com/donnemartin/system-design-primer/master/solutions/system_design/twitter/README.md (sdp-twitter-timeline.txt). "1,000 followers = 1,000 lookups and inserts" (step 3); "Twitter users with millions of followers could take several minutes to have their tweets go through the fanout process." (step 5); "If a user was not previously active in the past 30 days, we could rebuild the timeline from the SQL Database" (step 8).

Checked against the tools and docs as of 2026-10-17.