← Lessons

quiz vs the machine

Gold1430

System Design

The News Feed Design Recap

Assembling each user feed through fan out, caching, and ranking at scale.

5 min read · core · beat Gold to climb

The feed in one picture

A news feed shows each user recent posts from accounts they follow. The hard part is scale, one post may need to reach millions of feeds, and feeds are read constantly. The design balances write cost against read cost.

Fan out strategies

  • Fan out on write, or push, precomputes each follower feed when a post is made. Reads are fast lookups, but a popular author triggers a write storm.
  • Fan out on read, or pull, builds the feed by querying followed accounts at request time. Writes are cheap, but reads are heavy.
  • A hybrid pushes normal authors and pulls celebrity posts at read time, avoiding the write storm while keeping common reads fast.

Serving the feed

  • Each user feed lives as a bounded list of post ids in a fast cache, rebuildable from the follow graph.
  • Reads fetch ids, then hydrate post content and media from their stores.
  • A ranking stage scores candidates by recency, affinity, and engagement instead of pure recency.

Paging

Feeds page with cursors that mark a stream position, avoiding the duplicates and gaps that offsets cause as new posts arrive.

Key idea

A news feed balances write and read cost using push, pull, or a hybrid fan out, serves bounded cached timelines that hydrate content, ranks candidates, and pages with cursors.

Check yourself

Answer to earn rating on the learn ladder.

1. What is the central tradeoff in feed design?

2. How does a hybrid fan out handle celebrity posts?

3. Why do feeds page with cursors instead of offsets?