Skip to the guide

Fan-out on write vs fan-out on read

IntermediatePattern5 pages

A hotel can serve breakfast two ways. The kitchen can make up a tray for every room the night before and leave it outside each door, or it can lay out a buffet where each guest walks past every counter filling a plate. Trays cost the kitchen work for every room, eaten or not, while the buffet costs each guest a walk. Most hotels mix the two, with trays for the usual and the famous pastry left on one counter that every guest passes.

Each guest is a reader, and her tray is her feed, built when posts are written: fan-out on write, or push, carried by the kitchen staff, here the fan-out workers. The buffet is fan-out on read, or pull, each counter a followed account: the feed gathered from all of them on opening. The famous pastry is a celebrity's posts, kept once and merged in at read time. It's the first deep dive of most feed questions, and interviewers listen for each side's cost in numbers and where you draw the line. The move: push each post into followers' feeds, except from accounts so big that one post would hold up everyone else's, and pull those when a feed is read.