AlgoMaster Logo

Design Social Media News Feed System

Ashish

Ashish Pratap Singh

21 min read

Building such a system that delivers this experience to 100 million+ daily active users (DAUs) is anything but simple.

It brings up several complex challenges like:

  • How do we process and store the massive volume of new posts generated every second?
  • How do we efficiently support rich media like high-quality images and videos?
  • How do we ensure each user's feed updates in near real-time?
  • How do we handle the “celebrity” problem, where one post needs to reach millions of followers quickly?
  • How do we personalize the feed beyond simply showing the latest posts?
  • How do we avoid showing the same post to a user repeatedly?

In this chapter, we’ll start with a basic version of a news feed system and evolve it step by step into a robust, scalable and reliable distributed architecture.

Let’s start by clarifying the requirements.

1. Requirements

Before we jump into the design, let’s define what our “news feed” system needs to support, both functionally and non-functionally.

Functional Requirements:

  • Users can create posts containing text, images, or videos.
  • Users can follow other users (friends or connections)
  • Users can view a personalized news feed consisting of relevant and recent posts from people they follow
  • Users can like and comment on posts.
  • New posts should appear in a user’s feed within a few seconds
  • The system must handle users with very large followings, such as celebrities or influencers

Non-Functional Requirements:

  • Scalability: Support extremely high read (news feed fetches) and write (post creations, likes, comments). The system should scale horizontally to handle growth.
  • Availability: Ensure high availability (99.99% or higher), even under heavy load or partial system failures.
  • Low Latency: Serve news feed requests quickly (e.g. under 500ms). New posts should propagate to followers’ feeds within a few seconds.
  • Eventual Consistency: The system can tolerate slightly stale data (e.g., a like count that lags by a few seconds) in favor of availability and performance.
  • Reliability: Guarantee that no posts, likes, or comments are lost.

With these requirements in mind, we’ll now design the system in stages, starting from a naive version and incrementally adding the necessary components and optimizations.

2. Step-by-Step Design

Premium Content

This content is for premium members only.