System Design · Architecture under constraints

How would you design a news feed?

Mediumnews feedfan-outrankingUpdated Oct 2026
Quiz this track

Short answer

Choose fan-out on write for fast reads, fan-out on read for cheap writes, or a hybrid. Celebrity accounts usually need the read path to merge their posts, with caching and ranking on top.

Assume a social feed where users follow others, see recent and ranked posts, and scroll with pagination. Reads vastly outnumber writes, and the product tolerates a short delay before a new post appears for followers. The key decision is where the fan-out happens.

Fan-out strategies

  • Fan-out on write: when a post is created, insert its id into every follower's feed list, so reads are a simple lookup
  • Fan-out on read: store posts by author and merge the followees' posts at read time, so writes are cheap
  • Hybrid: precompute feeds for normal users and merge celebrity posts at read time
  • Write fan-out costs O(followers) per post and can be enormous for a celebrity
  • Read fan-out costs O(followees) per request and can be large for users who follow thousands

The hybrid is common because it handles the tail. Precompute each active user's feed from normal accounts, then merge in posts from a small set of high-follower accounts at read time. Use a per-user feed list in a partitioned store with a capped length, and paginate by a stable cursor rather than an offset.

Ranking adds another layer. The candidate set is assembled from the feed list, filtered for blocks and privacy, then scored by recency, affinity and engagement. Keep the ranking model out of the storage path; store candidates and compute scores in a service that can change independently. Cache ranked pages briefly because ranking is expensive.

Feed consistency is usually eventual. A user may not see their own post immediately if fan-out is asynchronous. Special-case the author's own view by merging their new posts directly, and make the pagination cursor stable so items do not jump between pages.

Follow-ups you should expect

Interviewers use these to check whether the first answer was understanding or memorisation.

  1. 1How do you handle a user with millions of followers?
  2. 2Why is offset pagination problematic for a feed?
  3. 3How do you avoid showing deleted or blocked content?
  4. 4What would you cache and for how long?

Say it in the interview

The core choice is fan-out on write versus read. Write fan-out makes reads fast but explodes for celebrities, while read fan-out makes writes cheap but makes each read merge many authors. I usually use a hybrid: precompute normal feeds and merge high-follower accounts at read time. Ranking runs on the candidate set, pagination uses a stable cursor, and the system tolerates a short delay except for the author's own posts.

Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.

Related questions

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live System Design mock interview and get scored feedback on depth, clarity and confidence.