Twitter / X: Real-Time Timeline Generation & Fan-Out Architectures
Architect real-time social streams: Timeline service, Tweet ingestion, Fan-out on Write vs Read, Redis In-Memory timelines, and Snowflake IDs.
01.1. The Real-Time Feed Problem: User Timeline vs Home Timeline
Twitter (now X) operates under extreme read-heavy velocity, processing over 500 million tweets per day with traffic surges exceeding 150,000 tweets per second during global live events (such as the World Cup).
To architect this, Twitter divides feeds into two fundamentally different constructs:
- User Timeline (My Tweets): All tweets posted by a single specific user. This is trivial to serve via a sharded index lookup:
SELECT tweet_id FROM tweets WHERE user_id = ? ORDER BY timestamp DESC LIMIT 20. - Home Timeline (Followed Feed): The real-time composite stream of all tweets posted by everyone a user follows. If a user follows 1,000 accounts, computing this dynamically on every page refresh requires querying 1,000 separate user timelines, merging and deduplicating millions of records in memory, and sorting them chronologically.
Executing this query dynamically for hundreds of millions of active users would instantly crash relational database clusters.
Twitter Timeline Generation & Hybrid Fan-Out Architecture 🐦
Twitter Timeline Generation & Hybrid Fan-Out Architecture 🐦
Bifurcated Fan-Out on Write (Push) for regular users and Fan-Out on Read (Pull) for high-degree celebrity accounts.
Unlock Topic #263: Twitter / X: Real-Time Timeline Generation & Fan-Out Architectures
You are viewing a preview. The full in-depth engineering deep dive, interactive simulators, architecture flowcharts, and self-assessment quizzes for this topic are available with Pro or Lifetime Access.
Failure modes, high-throughput bottlenecks, and real FAANG implementation decisions.
Interactive system topology diagrams, live parameter simulators, and downloadable SVG charts.
Staff-level multiple-choice quiz questions with instant feedback and answer explanations.
Firebase Google authentication automatically syncs your completed topics and quiz scores.
How clear and staff-actionable was this system breakdown?