KatInterview

Build a Short-Post Social Feed Platform at Scale

System DesignModel answer
MediumModel answerSystem Designsystem-designnews-feedfan-out

Last updated

Design a backend for a social platform where users publish brief posts, follow each other, and read a recent-posts home feed, covering feed delivery, storage, caching, and abuse controls.

You are asked to design the backend for a social platform in which people publish short text posts and read a personalized feed of what the accounts they follow have published recently.

Required capabilities

  • A user can publish a short post.
  • A user can follow and unfollow other accounts.
  • A user can open a home feed showing recent posts from the accounts they follow.
  • The system must handle both a heavy read load and a heavy write load.

What your answer should cover

  1. Your assumptions about scope and scale, with rough back-of-envelope numbers.
  2. The main APIs and the data model.
  3. How the home feed is produced. Compare computing it when a post is written with computing it when the feed is read, and say whether you would combine them.
  4. Storage technology choices, caching layers, pagination, and how posts are ordered or ranked.
  5. Consistency expectations, for example how soon a new post should show up for followers and for its author.
  6. Operational concerns: rate limiting, spam and abuse handling, and monitoring.

You may answer verbally, supported by structured notes or a rough diagram. State your trade-offs explicitly.

Hints

Hint 1

Do the arithmetic early: posts per second, feed reads per second, and especially the number of feed insertions per second if every post is copied to every follower. That last figure should drive your core design choice.

Hint 2

Think about accounts with an enormous number of followers and accounts that rarely log in. A single strategy for all users is likely to waste work or hurt latency for one of these groups.

Hint 3

Use time-sortable IDs and cursor-based pagination, store only post IDs in cached feeds, and fill in post contents at read time. This also makes deletes and unfollows easier to handle.

Hint 4

For operations, think about what signal tells you the feed is stale (for example, queue consumer lag), and which limits and checks belong synchronously on the write path versus asynchronously afterwards.