News Feed System Lifecycle Visualization
Walk through a scale-out news feed lifecycle from publishing and moderation to fan-out, timeline cache reads, hydration, ranking, and recovery.
Continue with the guided workspace
Use the paired workspace to connect this guide's mental model with live component state, visible signals, and the outcome each step or scenario is meant to prove.
Mental Model
A scale-out News Feed system must balance low read latency (sub-100ms) with high write volumes. Standard architectures utilize a hybrid fan-out model that separates normal users from high-following celebrity users, pre-computing timelines in memory caches while retrieving and merging celebrity activity on demand.
The paired simulator makes the push-versus-pull tradeoff observable through cache state, celebrity behavior, and request latency.
Components and Why They Exist
Client Nodes
Client nodes represent active end users who publish posts (writes) or fetch their home feed timelines (reads). Outbound request particles distinguish write operations (orange/purple) from timeline reads (blue) while tracking client-perceived request latency.
Load Balancer & Web Server
The load balancer and web server tier acts as the perimeter gateway that distributes requests across the application layer and protects internal services. Incoming client HTTP traffic passes through rate-limiting rules here before routing writes to the Post Service and reads to the Feed Service.
Post Service
The Post Service manages the initial write pipeline whenever an author publishes new content. During publishing, it coordinates pre-write moderation checks, persists the source-of-truth post record to the Metadata DB, and dispatches an asynchronous fan-out task when the author is a standard user.
Fan-out Service
The Fan-out Service offloads the heavy CPU and network work of updating follower timelines from the synchronous write path. It resolves the follower graph of a regular author and pushes the new post ID into each followerβs pre-computed timeline in the Feed Cache, with the fan-out queue length metric reflecting write backlog under burst traffic.
Feed Cache (Redis)
The Redis Feed Cache provides sub-15ms in-memory retrieval of chronological post ID lists, shielding the database from repetitive timeline queries. Active usersβ pre-computed timelines live in these cache slots, driving a high cache hit ratio along the read path.
Metadata Database (Metadata DB)
The Metadata DB serves as the persistent relational or document store for complete user profiles and post payloads. It commits newly published posts, serves indexed read-time queries for celebrity authors who bypass push fan-out, and supplies full post payloads during hydration.
Feed Service
The Feed Service handles user read requests to assemble each home feed. It fetches the pre-computed post ID list from the Feed Cache, queries the Metadata DB for unpushed celebrity posts, merges and hydrates the full post objects, and runs the ranking model while updating read latency metrics.
Edge Cases and Misconceptions
Fan-out Write Amplification (The Celebrity Pitfall)
A common misconception is that a single fan-out on write (push) model works for all users. If a celebrity with 50 million followers publishes a post, pushing that post ID to 50 million feed caches instantly overloads memory queues and Redis write channels. A hybrid model is required: celebrity posts bypass fan-out entirely, writing only to the database, and are dynamically pulled and merged by the Feed Service during a followerβs read request.
Cache Stampede and Database Overload
When an in-memory Feed Cache fails or entries expire simultaneously, incoming read requests fall back to querying the database directly. This creates a cache stampede (or thundering herd) where the Metadata DB is bombarded with complex timeline compilation queries, leading to server timeouts and cascading failures.
Hydration Overhead vs. Caching complete Posts
To conserve expensive RAM, feed caches typically store only a list of 64-bit post IDs rather than complete post bodies and media objects. The tradeoff is that the read path must perform a βhydrationβ stepβquerying the Metadata DB or a secondary document cache to fetch the actual post content before returning it to the user. This makes database read IOPS a key scalability bottleneck.
Common Questions
What is the difference between Push and Pull models in a News Feed?
The Push (Fan-out on write) model inserts posts into all follower caches when a post is created. The Pull (Fan-out on read) model fetches posts from authors at the moment the follower requests their feed. A hybrid model pushes normal user posts to follower caches but pulls celebrity posts on demand to avoid write amplification.
How are celebrity posts handled to prevent write amplification?
Celebrities have large follower counts. Pushing to all their caches creates massive write amplification. Instead, celebrity posts bypass the Fan-out Service and write only to the Metadata DB. When a follower requests their feed, the Feed Service queries the DB to pull celebrity posts and merges them with the cached timeline.
Why is Feed Cache critical in this architecture?
Querying the database to fetch and rank posts for every user request causes huge read latency and DB overload. Caching the pre-computed feed timelines in memory (e.g. Redis Clusters) allows sub-15ms reads.
What is post metadata hydration?
To save cache memory, feed cache stores only Post IDs rather than complete post objects. When retrieving the feed, the Feed Service retrieves these IDs from the cache, fetches details (user profiles, post text, media links) from the Metadata DB, and merges them to form the final response.
How is feed generation latency optimized?
Pre-computing the feed timelines (Push/Fan-out on write) shifts work from read-time to write-time, enabling fast sub-15ms feeds. For celebrities, bypassing push avoids cache lockups, and using efficient DB queries (e.g. index on authorId and timestamp) ensures pulling celebrity posts on read-time is quick.
What is write amplification and why does it occur?
Write amplification occurs when a single write request triggers multiple subsequent writes. For a news feed system, if a user has 10 million followers, publishing one post means the system must write 10 million timeline cache entries. A hybrid model selectively disables push for celebrities to keep write QPS manageable.
How does feed ranking affect latency?
Moving from chronological sorting to engagement scoring requires executing ranking models (which calculate scores based on user behavior, post features, and affinity) for every post on the read path. This increases the CPU overhead of the Feed Service, causing feed retrieval latency to rise from ~15ms to ~45ms.