Katkat

Design a Ranked Home News Feed for a Large Social Network

MetaSoftware Engineer · Onsite

Last updated

A system design question on building the home news feed of a large social network: publishing posts and serving each user a ranked, paginated feed of posts from the accounts they follow. It tests fan-out strategy, accounts with huge follower counts, ranking under a latency budget, and correctness for deletes and privacy.

Design the home news feed for a large social network. When users open the app, they see a ranked, infinitely scrollable list of recent posts from the friends and pages they follow. When they publish a post, it should show up in their followers' feeds.

Design the backend that accepts new posts and serves each user's feed.

Constraints and Clarifications

  • Media storage and delivery can be treated as an existing service; focus on post metadata and feed assembly.
  • Scale, freshness targets, and ranking signals are not given; ask for them or state assumptions.

Clarifying Questions

  • How many daily active users are there, how many accounts does a typical user follow, and what is the largest follower count to support?
  • Is the feed ranked or chronological, and which signals may ranking use?
  • How quickly must a new post appear in followers' feeds?
  • Are ads or recommended posts from accounts the user does not follow in scope?
  • How must deletions, edits, and audience restrictions on a post be reflected in feeds that already contain it?

Hints

Hint 1

Where to pay the cost: Decide whether a feed is assembled when a post is written or when the feed is read, then test that choice against an account with an enormous follower count.

Hint 2

Narrow before you rank: Scoring every post a user could possibly see on each request is too slow; think about what produces a small candidate set first.

Follow-up questions

  • An account with a very large follower count publishes a post. Walk through what happens on the write path and on a follower's next read.
  • How do you make sure a deleted post, or a post whose audience was narrowed, disappears from feeds quickly?
  • How would you serve the feed of a user returning after months of inactivity?
  • How would you test a new ranking model without hurting feed latency?