Learning on Web Dev Open is free for all.

Interview Prep · System DesignDesign a news feed
← System Design

Design a news feed

Medium45 minFree, no account

Fan-out on write versus on read, and the celebrity who breaks both.


The question

Design the feed for a social network: users follow other users and see their posts, newest first.

Two hundred million daily users. Assume the follow graph is heavily skewed: most people follow a few hundred accounts, a handful of accounts have tens of millions of followers.

Functional
  • A user can post.
  • A user can follow and unfollow.
  • A user can read a feed of posts from the people they follow, newest first, paginated.
Non-functional
  • 200M DAU × 2 posts/day; feed read 20× per user per day → ~300k feed reads/sec at peak.
  • Feed read p99 under 200ms.
  • The feed may be up to a few seconds stale. Posting may take a second.
45:00Commit to an answer before you open the solution. Reading it first teaches you to recognise good answers, which is not the skill being tested.

Stuck?

0 of 3 hints taken

The worked solution

written by a person · not a grade

Score yourself

0 of 5 marked
  • Computed the read cost and used it to reject the normalised design20
  • Described fan-out on write with the queue, the cap, and ids rather than bodies25
  • Found the celebrity problem unprompted and split the population30
  • Used cursor pagination and said why offset breaks here15
  • Named a degradation when the fan-out workers fall behind10

We run no AI here and nothing on this page grades you. The score is yours, and the useful number is the one you get on the same problem a month from now, cold.

kept in this browser only