Skip to main content
System DesignInterview Prep

Design a News Feed: System Design Interview Walkthrough

How to answer the news feed (Facebook, Instagram, Twitter timeline) question: fan-out on write vs read, the celebrity problem, feed ranking, storage, caching and the trade-offs interviewers want named.

InterviewPilot TeamOctober 17, 20264 min read

The news feed question is about one idea: where do you do the work, at write time or read time? See the cheat sheet for the general framework.

1. Requirements

Functional: create posts, follow users, view a feed of followed users' posts, pagination, optionally ranking and media. Non-functional: fast feed loads, high availability, eventual consistency is acceptable, large read:write ratio.

2. Core components

  • Post service + post store (posts by ID)
  • Social graph service (who follows whom)
  • Feed service (builds and serves feeds)
  • Feed cache (per-user list of post IDs)
  • Media storage and CDN

3. Fan-out on write (push)

On a new post, a worker looks up the author's followers and prepends the post ID to each follower's feed list in the cache.

  • Pros: reads are a single cache lookup
  • Cons: heavy for users with huge followings; wasted work for inactive followers

4. Fan-out on read (pull)

At read time, fetch the people you follow, pull their recent posts and merge.

  • Pros: cheap writes, no wasted precomputation
  • Cons: slow reads, heavy graph and post queries on every load

5. Hybrid (the usual answer)

  • Normal users: fan-out on write
  • High-follower accounts: skip fan-out; their posts are merged into the feed at read time
  • Skip precomputing for inactive users and rebuild on login

6. Reading the feed

  1. Load the precomputed list of post IDs from cache
  2. Merge recent posts from followed celebrity accounts
  3. Hydrate IDs into post objects (batch lookups, cached)
  4. Rank, then return one page with a cursor

7. Ranking

Begin with reverse-chronological. Mention that a production system scores candidates using recency, affinity with the author, post type and engagement signals, usually in a separate ranking service.

8. Edge cases and follow-ups

  • Deleting a post or unfollowing: remove from feed caches lazily or filter at read time
  • Cache size: keep only the latest N IDs per user
  • Hot posts: cache hydrated objects; use a CDN for media
  • Consistency: it's fine if a new post appears seconds late

Estimating the numbers

Assume 500 million users, 100 million daily actives, each following 200 accounts on average and posting once a day.

  • New posts per day: about 100 million.
  • Fan-out on write: 100 million posts x 200 followers = 20 billion feed-list inserts per day, roughly 230,000 per second. Large but feasible with sharded Redis.
  • Feed reads: if each active user opens the feed 10 times a day, that is a billion reads, roughly 12,000 per second on average, with peaks several times higher.

The write amplification explains why celebrity accounts need special handling.

The feed cache

Each user's feed is a capped list of post IDs, for example the latest 500, stored in Redis. Reading a page means taking a slice, then hydrating post objects in a batch from a post cache. This keeps the read path to two or three fast lookups.

Ranking in layers

  1. Candidate generation: gather recent posts from the precomputed feed plus pulled celebrity posts.
  2. Scoring: a model estimates relevance using recency, author affinity, content type and engagement.
  3. Filtering and diversity: remove duplicates, blocked users and over-repeated authors.
  4. Return the page with a cursor.

You do not need ML detail in most interviews. Show that you understand the stages and that ranking runs on a small candidate set, not the entire post table.

Pagination with cursors

Use the last post's ID or timestamp as the cursor. Offset-based pagination breaks when new posts are inserted while the user scrolls, causing duplicates or skips.

Dealing with deletes, edits and privacy

  • Delete: mark the post deleted and filter at hydration time; lazily clean feed lists
  • Edit: update the post store; feeds hold only IDs, so edits propagate automatically
  • Privacy changes: filter by visibility at read time, since precomputed feeds can be stale

Interview tips

State the read-heavy assumption early, present both fan-out strategies with their costs, then land on the hybrid. Interviewers want to hear the celebrity problem unprompted.

Frequently asked questions

Was this article useful?

Discussion

No comments yet. Been through an interview like this? Your experience could help the next candidate.

You’re posting anonymously — it appears after a quick review. Sign in to post under your name instantly.
0/2000

Bring backup into your next round.

Install InterviewPilot, upload your resume, and walk in with structured answers a keystroke away — visible to you and nobody else.