Pattern

Fan-out

Decide whether one write becomes many at publish time, many reads merge at request time, or both — the choice that shapes an entire feed, chat, or notification system.

What it is

Fan-out is the decision of when a single event (a post, a message, a notification) turns into the multiple copies its many recipients will eventually see. Fan-out-on-write pushes the work to publish time: the moment something happens, the system writes a copy into every recipient's own list, so a later read is a single cheap lookup. Fan-out-on-read defers that work to request time: nothing is duplicated up front, and a read gathers together everything relevant from each source the reader cares about. Real systems almost never pick one exclusively — the interesting design work is choosing a threshold and building the hybrid, because the two approaches fail in opposite ways at opposite ends of the popularity distribution.

When it applies

Tells in the problem

The classic mistake

Treating fan-out as a single global decision rather than doing the arithmetic per producer size is where designs go wrong — applying fan-out-on-write uniformly means a small number of huge producers generate an astronomical, sometimes system-breaking number of writes per event, while applying fan-out-on-read uniformly means every reader's request fans out into as many lookups as sources they follow, which is slow whenever that number is large. The fix is always the same shape: pick a threshold (based on what the read path can afford to merge live, not an arbitrary round number), fan out on write below it, and merge at read time above it — and back that threshold with the actual numbers (follower counts, read-path fetch budget) rather than asserting a hybrid exists without showing why the threshold sits where it does.

Questions to start with

All 3 fan-out questions

Problem statement, examples and hints are free on every page; the worked approach, solution and tests are in the company guides.

Free starter pack

13 must-tier questions with full solutions

Sign in with an email — no purchase — and read them in the full reader.

No password, no spam. One sign-in email; you can read the pack in the full reader.