KatInterview

Design a Social Media Activity Feed at Scale

System DesignModel answer
MediumModel answerSystem Designfeed generationfan-outcaching

Last updated

Design the core feed delivery system for a social platform, focusing on how to balance write amplification against read latency for users with vastly different follower counts.

Design a Social Media Activity Feed at Scale

You are building the activity feed for a social platform. When someone posts content, their followers should see it in their personalized feed. The core challenge is doing this efficiently when some users have 200 followers and others have 10 million.

What the system needs to do

  1. Allow users to publish posts (text and attached media).
  2. Allow users to follow and unfollow other accounts.
  3. Serve each user a personalized, reverse-chronological feed of posts from accounts they follow.

Scale and quality targets

  • Active users: 100 million per day.
  • Feed load time: under 200ms at the 99th percentile.
  • Consistency: feeds do not need to update in real time — a delay of a few seconds is fine.

What your answer should cover

  1. API design — endpoints for publishing a post, following/unfollowing, and retrieving a feed with pagination.
  2. Data model — what you store, where you store it (SQL vs. NoSQL and why), and how you structure it.
  3. Feed generation architecture — how a new post makes its way into followers' feeds; specifically, how your approach differs for a regular user versus an account with millions of followers.
  4. Caching strategy — what lives in cache, how it is keyed, and how you handle consistency between cache and storage.
  5. Pagination — how a client requests successive pages of the feed without missing posts or seeing duplicates.

Ground your design in rough numbers. Interviewers want to see estimates drive decisions, not decorate them.

Hints

Hint 1

Start with a back-of-envelope calculation. Posts per day, feed reads per day, and average follower count each have a direct implication for the design — write them down before drawing any boxes.

Hint 2

Consider what happens when a single write must propagate to 10 million followers. That edge case is the crux of the problem, and the answer is not to treat every user the same way.

Hint 3

Your feed does not need to store full post content — storing only post IDs and resolving them at read time keeps the cache smaller and makes edits and deletes much cheaper.