A deep dive into how social media home feeds scale from a naive read-time query to production-grade architectures. Covers fan-out on read versus fan-out on write, the single-writer rule for transactional consistency, write amplification caused by celebrity accounts with millions of followers, and the hybrid fan-out approach that combines materialized timelines with a celebrity index merged at read time. Also touches on ranked feeds (candidate generation, light/heavy ranking, re-ranking) as used by Twitter's open-sourced recommendation algorithm, and operational metrics like consumer lag and commit-to-visible latency. Ends with a plug for a system design practice tool called Katabench.

10m read timeFrom milanjovanovic.tech
Post cover image
Table of contents
Fan-Out on ReadThe Single-Writer RuleFan-Out on WriteWrite AmplificationHybrid Fan-OutRanked FeedsOperating the PipelineSummary

Questions this post answers

What is the difference between fan-out on read and fan-out on write for a social media feed?

Fan-out on read computes the feed at query time by merging posts from all followed accounts live, while fan-out on write materializes each follower's timeline at publish time so reads become a single lookup. Twitter's numbers show roughly 300,000 timeline reads per second against about 5,000 new tweets, a 60-to-1 read-to-write ratio that justifies shifting the work to writes. Explore more real-world system design tradeoffs like this one on daily.dev.

How do social media platforms handle celebrity accounts with millions of followers in feed fan-out systems?

Celebrity accounts are routed to a hybrid fan-out approach where ordinary authors keep fan-out on write, but celebrity posts are appended to a compact index keyed by author instead of being pushed to every follower's timeline, making publishing a single write regardless of follower count. At read time, the feed API merges the user's materialized timeline with recent candidates from celebrity indexes they follow. daily.dev helps engineers comparing feed architectures find writeups like this.

How does Twitter's ranked feed algorithm decide what posts to show?

Twitter's open-sourced recommendation algorithm generates roughly half its candidates in-network and half out-of-network, then funnels them through a cheap light ranker to trim thousands down to a few hundred, before a neural heavy ranker scores each surviving post by predicting engagement probabilities like, reply, repost, and dwell time, followed by product rules such as diversity and integrity filters. Follow daily.dev for deeper dives into ranking pipelines behind major feed products.

394 Impressions