System design · must-tier · asked at Amazon, Apple, Google, Meta, Microsoft, Netflix

Design a News Feed

mediumhldfanoutrankingcaching

Prompt

"Design a personalised feed: users follow sources, sources publish items, and each user sees a ranked feed of recent items from what they follow. Reads must be fast."

Clarifying questions

  • Who publishes? Users and organisations. Follower counts are skewed: most have under a thousand followers, a few have tens of millions.
  • Feed contents? Items from followed sources, ranked, not strictly chronological. Ads and recommendations are out of scope but the ranking hook should allow them.
  • How fresh? An item should be visible to followers within a few seconds for typical publishers; a minute is acceptable for the largest ones.
  • Feed depth? Users scroll a few hundred items at most; older content is reachable via the source's own page.
  • Interactions? Likes and comments exist but are separate services; the feed needs their counts for ranking, approximately.
  • Consistency? A user must see their own post in their own feed immediately. Otherwise eventual is fine.
  • Ranking model? Assume a scoring service exists: given a user and a candidate set, it returns scores. We design how candidates are produced and how scores are applied.

Requirements

Functional

  • Publish an item; it appears in followers' feeds.
  • Read a user's feed: the first page and subsequent pages, ranked.
  • Follow and unfollow, with the feed reflecting changes on the next read.
  • Author sees their own item immediately.

Non-functional

  • Feed read p99 under 200 ms for the first page.
  • Publish visible to followers within seconds (large publishers within a minute).
  • Read-heavy: reads outnumber writes by two orders of magnitude.
  • Degrade gracefully: if ranking is unavailable, serve a chronological feed rather than an error.

Back-of-envelope

  • Assume 500 million daily active users, each opening the feed 10 times per day and pulling 2 pages of 20 items: 10 billion feed reads/day, ~115 K reads/s average, ~350 K/s peak.
  • Publishing: 50 million items/day, ~580/s average, ~2,000/s peak. Average followers per publisher: 200. Fan-out writes: 50 M x 200 = 10 billion feed-entry writes/day, ~115 K/s average. Fan-out volume equals read volume; that is the first sign that pure write-time fan-out is not free.
  • The tail: suppose 10,000 accounts have 10 M+ followers and post 5 times a day. Their fan-out alone: 10,000 x 5 x 10 M = 500 billion writes/day, 50x everything else. This is the arithmetic that forces the hybrid design.
  • Feed storage per user: keep the most recent 500 entry ids at 16 bytes each (item id, score or timestamp) = 8 KB; 500 M users x 8 KB = 4 TB in a cache tier. Comfortably in memory across a cluster.
  • Item storage: 50 M items/day x 1 KB (text, refs, counts) = 50 GB/day, ~18 TB/year. Media elsewhere.
  • Follow graph: assume 100 billion edges at 16 bytes = 1.6 TB; sharded by follower for "who do I follow" and by followee for "who follows me". Both directions are needed.

Last reviewed 8 September 2026