Back to sketch

SYSTEM DESIGN SKETCHBOOK / PRACTICE SHEET / NO. 15

Design a ranked news feed

Advanced · 50 min · Feeds & social graphs

When someone opens a social app, they see a feed of posts from friends, pages they follow and groups they belong to, ordered by what they are most likely to care about rather than by time. Every post has an audience set by its author (public, friends, friends except some people, a group), and people block each other.

Requirements

  • Return a ranked feed mixing posts from friends, followed pages and joined groups.
  • Never show a post to someone outside its audience, and never show posts between users who have blocked each other.
  • Paginate within a feed session without duplicates or skipped posts, even while new posts arrive.
  • Let a pull-to-refresh bring in newer posts as a new session.

Constraints and assumptions

  • 500 million daily active users, each opening the feed about 10 times a day; peak 150,000 first-page requests per second.
  • A typical user has 400 friends, follows 50 pages and belongs to 20 groups; their sources produce 1,500 to 3,000 eligible posts over the last two days.
  • The full ranking model costs about 0.2 ms of compute per candidate; first page p99 under 500 ms end to end.
  • Audience changes, unfriends and blocks must apply from the next feed request onward.
  • A page holds 10 posts; a session lasts about 5 minutes and rarely goes past 100 posts.

Out of scope for the first sketch

Ads in the feed · Training the ranking models · Comments and reaction counts on posts

Draw your design

Rough math and notes

Done on paper? Compare with the worked approaches