πŸš€
🎨 Designing Systems
πŸ“± News Feed

Design a News Feed (aka Twitter) πŸ“±

A news feed is a constantly updating list of posts and updates from people you follow. It is the core feature of platforms like Twitter, Instagram, and Facebook.

🌍
References & Disclaimer

This content is adapted from Mastering System Design from Basics to Cracking Interviews (Udemy). It has been curated and organized for educational purposes on this portfolio. No copyright infringement is intended.


πŸš€ Introduction

Designing a news feed at scale involves handling massive "Fan-out" (distributing one post to millions of followers) while maintaining sub-second latency for feed loads.

Core Functional Requirements

  • Post Updates: Users can post short text updates and media.
  • Follow/Unfollow: Users can follow others to see their updates.
  • View Timeline: A feed of posts from all followed accounts, sorted by time or relevance.
  • Engagements: Support for likes, replies, and retweets.

Non-Functional Requirements

  • Low Latency: Feeds must load instantly (< 200ms).
  • High Availability: System must remain accessible even during viral events.
  • Scalability: Support hundreds of millions of daily active users (DAU).
  • Data Consistency: Posts should not be missing or duplicated in the feed.

πŸ“Š Scale Estimation

To design for the right scale, we assume Twitter-like volume:

  • DAU: 200 Million
  • Tweets/day: ~1 Billion
  • Feed Requests/day: ~2 Billion (Users check 10 times a day)
  • Media Storage: ~300M uploads/day requiring ~100-500TB of storage.
  • Read/Write Ratio: Extremely read-heavy (~80% reads).

πŸ“ High-Level Architecture

The system is split into two primary flows: Write Path (posting a tweet) and Read Path (loading the timeline).


πŸ”‘ Timeline Generation Strategy

The biggest challenge is Fan-out: how do we show one tweet to millions of followers?

Fan-out on Write (Push Model)

  • Mechanism: When Bob tweets, the system pushes the tweet ID directly into the pre-computed timeline caches of all his followers.
  • Pros: O(1) read latency. Loading the feed is just a simple cache fetch.
  • Cons: Write Storms. If a celebrity with 10M followers tweets, the system must perform 10M writes instantly.

πŸ—οΈ The Final Design

News Feed Final Design


πŸ› οΈ Bottlenecks & Challenges

  1. Hotspotting: Celebrities with 100M+ followers cause significant traffic spikes. Sharding by user_id and using the Hybrid Fan-out model mitigates this.
  2. Media Delivery: Timeline content is heavy. Using a Global CDN is essential to ensure images and videos load seamlessly across the world.
  3. Write Amplification: A single tweet results in many operations (DB write, Media link, Fan-out, Notifications). Decoupling these via Asynchronous Queues (Kafka) ensures the "Tweet Button" is always responsive.

πŸ’‘ Top Interview Questions

Q: Why use Cassandra for tweets? Cassandra is optimized for high-volume writes and is highly scalable geographically. It handles a massive number of small rows (tweets) efficiently.

⚠️

Q: How do you handle pagination? Use Cursor-based pagination (using the tweet ID or timestamp) instead of Offset-based. Offsets become increasingly slow as you scroll deeper into the feed.

Β© 2026 Driptanil Datta. All rights reserved.

Software Developer & Engineer

Disclaimer:The content provided on this blog is for educational and informational purposes only. While I strive for accuracy, all information is provided "as is" without any warranties of completeness, reliability, or accuracy. Any action you take upon the information found on this website is strictly at your own risk.

Copyright & IP:Certain technical content, interview questions, and datasets are curated from external educational sources to provide a centralized learning resource. Respect for original authorship is maintained; no copyright infringement is intended. All trademarks, logos, and brand names are the property of their respective owners.

System Operational

Built with Love ❀️ | Last updated: Mar 16 2026