Fan-out Strategies for Feeds
You'll learn to
- -Compare fan-out-on-write and fan-out-on-read
Fan-out on Write (Push)
The moment someone posts, the system immediately copies that post into every one of their followers' precomputed feed lists. Reads are then extremely cheap: just fetch the already-assembled list. The catch is the "celebrity problem": a user with 50 million followers turns one post into 50 million writes.
Fan-out on Read (Pull)
Nothing is precomputed. When a user opens their feed, the system fetches recent posts from everyone they follow and merges them on the spot. Writes stay cheap no matter how many followers someone has, but reads get expensive for a user who follows thousands of accounts.
The Hybrid Approach
Most large-scale feed systems use both: push (fan-out on write) for ordinary accounts, and pull (fan-out on read, merged in at request time) specifically for celebrity accounts whose follower count would make push prohibitively expensive. This is exactly the kind of "know the access pattern, then pick per-case" trade-off this course keeps returning to.
Regular users are fanned out on write for fast reads; celebrity posts are pulled and merged in at read time instead.
The Capstone module later in this course walks through a full news feed design end to end: real follower-count math, the exact write-amplification numbers, and the hybrid threshold logic in detail.
Why is fan-out-on-read actually fine for a celebrity's followers, when fan-out-on-write for that same celebrity would be a disaster?
"Because pull is generally more efficient than push."
"It's specifically about which side of the relationship pays the cost. Fan-out-on-write cost scales with the poster's follower count, unbounded for a celebrity. Fan-out-on-read cost scales with how many accounts the READER follows, which is naturally bounded (a person only follows so many accounts, celebrity or not). Pulling a celebrity's posts at read time costs each reader one extra bounded lookup; fanning them out on write costs the system tens of millions of writes for a single post."
Which technique provides true bidirectional, low-latency communication?
Level 10 (News Feed) and Level 11 (Chat System) are this module's two flagship exercises.