System Design HLD Example: News Feed (Home Timeline)
The Katy Perry Problem
A news feed system builds personalized timelines by combining content publishing, graph relationships, and ranking.
🎯 System Scenario & Requirements
System Goal
A news feed system builds personalized timelines by combining content publishing, graph relationships, and ranking.
Actors & Components
- Application or API tier
- Core service under design
- Operator or SRE observer
Functional Requirements
- TLDR: A news feed system builds personalized timelines by combining content publishing, graph relationships, and ranking.
- The scalability crux is the fan-out amplified write path: a single celebrity post can trigger 100M writes.
- A hybrid fan-out strategy—push for normal users, pull for celebrities—is the industry standard for 99.99% availability.
Constraints & Assumptions
- Constraints are derived from the rebuilt scenario stages.
⚡ Execution Stages & Decision Trace
Stage 1 — News Feed: Use Cases, Actors, and Scale Requirements
Actors - Publisher / Author: Creates and posts content (text, media).
- Reader / Follower: Consumes a ranked home feed of followed users' posts.
Deep Dive
Scenario context
A news feed system builds personalized timelines by combining content publishing, graph relationships, and ranking. The scalability crux is the fan-out amplified write path: a single celebrity post can trigger 100M writes. A hybrid fan-out strategy—push for normal users, pull for celebrities—is the industry standard for 99.99% availability.
Imagine it’s 2013. Twitter is growing at a breakneck pace. Most users have…
This walkthrough focuses on The Katy Perry Problem.
Before making a design choice, clarify:
- Twitter is growing at a breakneck pace.
- Most users have a few hundred followers, and the system handles them easily by "pushing" new tweets into their home timelines at write-time.
- She has 100 million followers.
Concepts in play: system-design-hld-architectures, caching, graph-traversal-algorithms, event-driven-architecture
Stage 1 — News Feed: Use Cases, Actors, and Scale Requirements
- Actors - Publisher / Author: Creates and posts content (text, media).
- Reader / Follower: Consumes a ranked home feed of followed users' posts.
- System: Handles fan-out, ranking, and timeline materialization.
- Functional Requirements - Post Creation: Users can POST content with text/media.
Observable outcome: Functional Requirements - Post Creation: Users can POST content with text/media.
Stage 2 — Basics of News Feed Architecture
- At its heart, a news feed is a many-to-many relationship pipeline .
- Unlike a simple blog where one post is read by everyone, a feed is a personalized "inbox" for every user.
- Apache Kafka is the decoupling mechanism between post creation and fan-out.
- The posts.created topic is partitioned by author id , ensuring that all posts from one author are processed by the same fan-out worker partition and arrive in creation order.
Observable outcome: The posts.created topic is partitioned by author id , ensuring that all posts from one author are processed by the same fan-out worker partition and arrive in creation order.
End-to-end outcome
After working through the stages, you should be able to explain:
- The Celebrity Threshold Requires Continuous Calibration.
- Setting the celebrity threshold too low pushes too many accounts into pull fan-out, degrading read performance for mid-tier influencers whose follower lists still take seconds to query.
- A news feed is a read-heavy, write-amplified system.
- The core design tension is between write-time cost (fan-out to millions of followers) and read-time cost (merging posts from all followed authors on every page load).
Alternatives considered
The source focuses on one primary design. A second architecture is not compared, so no alternative is invented here.
Failure and degraded modes
The source does not isolate a separate failure mode. Limits that matter for the scenario are called out in the stage decisions above.
