Home / System Design / Design a News Feed

📰 Design a News Feed

Case Study ⏱ 9 min read

A news feed shows each user a personalised stream of posts from people they follow. The core challenge is delivering fresh feeds to millions of users cheaply — and the famous fan-out trade-off is at its heart.

1. Requirements

  • Functional: users post content; users see a feed of posts from those they follow, newest/most-relevant first.
  • Non-functional: very read-heavy, feed loads must be fast (<200ms), eventual consistency is acceptable (a post appearing a few seconds late is fine).

2. Two ways to build a feed

Fan-out on write (push): when a user posts, immediately write that post into the precomputed feed cache of every follower. Feed reads are then instant (just read your list). But a post by someone with millions of followers triggers millions of writes.

Fan-out on read (pull): store posts once; build each user's feed on demand by fetching recent posts from everyone they follow. Cheap writes, but reads are heavy and slower.

3. The celebrity problem &amp; the hybrid

Push breaks for celebrities (millions of followers → write storm); pull is slow for users who follow many people. Real systems use a hybrid: push for normal users, and pull for a small number of very-high-follower accounts, merging their recent posts into your feed at read time.

4. Storage &amp; caching

Posts live in a scalable store (wide-column like Cassandra suits high write volume). Precomputed feeds live in a fast cache (Redis lists) holding just the recent items. Media goes to blob storage behind a CDN. The fan-out work runs asynchronously through message queues.

5. Ranking

A chronological feed is simplest. A ranked feed scores posts by recency, engagement and affinity. Start chronological in an interview, then mention ranking as an extension so you don't over-scope.

Frequently Asked Questions

What is fan-out on write vs fan-out on read?
Fan-out on write pushes a new post into every follower's precomputed feed immediately, making reads fast but writes expensive. Fan-out on read builds the feed on demand from the people you follow, making writes cheap but reads heavier.
How do feeds handle celebrities with millions of followers?
With a hybrid approach: normal users get fan-out on write, while posts from very-high-follower accounts are pulled in at read time and merged into the feed, avoiding a massive write storm.