KatInterview

Design a Personalized Activity Feed for a High-Scale Social Platform

System DesignModel answer
MediumModel answerSystem Designfeedfan-outranking

Last updated

Design the backend that publishes user posts and serves each follower a ranked, paginated feed, handling celebrity accounts, deletions, and privacy at scale.

Personalized Activity Feed

A social platform wants to revamp the core feature its users interact with most: the home feed. When someone opens the app, they expect to see a freshly ranked, infinitely scrollable stream of posts from every account they follow. When they publish something new, their followers should see it promptly.

Your task is to design the backend that powers both sides of this: ingesting new posts and assembling each user's feed on request.

You do not need to design media storage or CDN delivery — treat those as existing services. Focus on post metadata, feed assembly, and ranking.

What to address

  • Overall architecture and data flow from post creation to feed retrieval
  • How you distribute a new post to all relevant followers (fan-out strategy)
  • How ranking works within a latency budget
  • Pagination that stays coherent as new posts arrive during a scroll session
  • Correctness: what happens when a post is deleted, edited, or restricted after it has already been fanned out
  • How the system stays healthy at peak load, and how it degrades gracefully if a component falls behind

Constraints and clarifications

  • Media assets (images, video) are out of scope; model a post as an ID, author ID, text, timestamp, and audience setting.
  • Exact scale, freshness SLAs, and ranking signals are intentionally left open — state your assumptions or ask clarifying questions before designing.

Clarifying questions worth raising

  • How many daily active users are there, and what does the follow-graph look like — typical follows per user and the largest follower count the system must support?
  • Is the feed ranked by relevance, or strictly chronological? If ranked, which signals are available (recency, engagement, relationship strength, etc.)?
  • What is the acceptable delay between a post being published and appearing in a follower's feed?
  • Are algorithmically recommended posts (from accounts a user does not follow) or ads in scope?
  • What consistency guarantees are required for deletes and audience-restriction changes — eventual is usually fine, but what is the upper bound?

Hints

Hint 1

Start by sizing the fan-out problem: if a user has 50 million followers and posts once, naively writing to 50 million feed rows synchronously will blow your latency and throughput budget. That asymmetry is the core tension the design has to resolve.

Hint 2

Think of feed assembly as two separate stages: candidate generation (which posts are even eligible for this user?) and ranking (in what order should they appear?). Separating them lets you tune each independently and apply ranking only to a manageable shortlist.

Hint 3

A cursor you hand back to the client should encode a stable position in the feed snapshot, not a raw offset. Consider what happens when 20 new posts arrive while a user is mid-scroll — you want to serve consistent pages without repeating or skipping posts.