Fan-out on write versus read, timeline caches, and Earlybird real-time search.
The Problem: Why Timelines Are Hard — Some 200M personalized merges, read-dominated by orders of magnitude, under 100 ms: the arithmetic that rules out simply querying the database. (4 min read)
Fan-out on Read (The Pull Model) — Cheap writes, brutal reads: merging every followed account's tweets at read time is the obvious design, and exactly why it fails at scale. (3 min read)
Fan-out on Write (The Push Model) — Precompute every follower's timeline when a tweet is posted: O(followers) writes buy O(1) reads, the right trade when reads dominate. (3 min read)
Write Amplification: Where Fan-out Breaks — One celebrity tweet becomes tens of millions of writes; the math of where push breaks, and why more hardware does not fix it. (4 min read)
The Hybrid Model (The Actual Answer) — Push for ordinary accounts, pull for celebrities, merge at read time; the follower cutoff is a business decision and the price is two code paths. (4 min read)
The Timeline Service: Redis Sorted Sets — A bounded Redis sorted set of about 800 tweet IDs per user: why IDs and not tweets, why the cap, and why it is a cache you can afford to lose. (8 min read)
Eventual Consistency and Out-of-Order Tweets — Fan-out is asynchronous, so a timeline is eventually correct; Snowflake IDs define the order, and tweets can still pop in out of order. (4 min read)
Earlybird: The Real-Time Search Index — Search is not the timeline system: a separate real-time inverted index answers which tweets contain a term (the Earlybird chapter goes deep). (2 min read)
The Algorithmic Timeline: Ranking on Top — Delivery produces candidates and an ML pipeline re-ranks them into For You; why ranking is layered on top of fan-out rather than fused into it. (4 min read)
Synthesis: How It All Interlocks — The read:write asymmetry seeds every decision, each layer's guarantee is paid for by another layer's cost, and the celebrity problem carries the load. (2 min read)
Self-Test — Six questions that connect fan-out, the hybrid cutoff, the timeline cache, consistency, ranking and search, with full answers. (5 min read)
The Named Components (Glossary) — The real Twitter systems the guide refers to, from Snowflake and FlockDB to Manhattan and Earlybird, each in a sentence. (1 min read)
The Social Graph: How Twitter Stores Followers and Following — FlockDB stores follower and following adjacency lists as two sharded copies, cached for fan-out; what a follow or unfollow touches. With the guide's primary sources. (4 min read)
Why the Timeline System Can't Answer Search — The timeline is indexed by relationship and search needs an index of content: different keys, different structure, no way to bolt one onto the other. (3 min read)
The Inverted Index: Terms to Tweets — Each term maps to a posting list of tweet IDs, a query is a posting-list intersection, and tokenization decides what is findable at all. (2 min read)
Query Serving: Root/Leaf Fan-Out — One query fans out to hundreds of chronologically sharded leaves; time-ordered shards let the root stop early, and tail latency is the cost. (2 min read)
Ranking Search Results: Recency vs. Relevance — Early Earlybird returned recency order; the modern product layers relevance on top, the same delivery/ranking split as the timeline, and feeds retrieval back into it. (2 min read)
Earlybird Self-Test — Questions on the inverted index, segments, the two tiers, query fan-out, ranking and rebuilds, with full answers and the primary sources. (5 min read)