interviewmind

Design a news feed

“Design a news feed” is a system design interview question. Design the home feed for a social app. Each user sees recent posts from the accounts they follow, newest first, and can scroll back through older ones. There are 300 million daily active users, each following about 200 accounts, and a few celebrity accounts have more than 50 million followers. Users publish 500 million posts a day, feeds are read about 100,000 times a second at peak, and a feed should load in under 200 ms. Below is what to cover and 3 hints; press Practice and Dana, the interviewer, asks it out loud while you sketch the design.

Updated · By InterviewMind

Practice this question

Free in your browser, no account.

The problem

System design

Design the home feed for a social app. Each user sees recent posts from the accounts they follow, newest first, and can scroll back through older ones.

There are 300 million daily active users, each following about 200 accounts, and a few celebrity accounts have more than 50 million followers. Users publish 500 million posts a day, feeds are read about 100,000 times a second at peak, and a feed should load in under 200 ms.

Things to cover

  • Building feeds when a post is written, or when a feed is read
  • Accounts with tens of millions of followers
  • Where posts and feeds are stored and cached
  • Pagination, and where ranking would fit in later

Hints

Open one at a time, and try the question again after each.

Hint 1

Estimate the fan-out first: 500 million posts a day, each delivered to about 200 followers, is 100 billion feed inserts a day, over a million a second. That number decides how much of each feed you can build ahead of time.

Hint 2

The core is a precomputed feed per user: a short list of post ids in a cache, filled in when someone they follow posts. Reading a feed is then one cache read plus a batch fetch of the posts.

Hint 3

The hard part is the account with 50 million followers, where pushing one post into every feed takes far too long. Skip the push for those few accounts, fetch their recent posts when a feed is read, and merge them in.

Practice it out loud

In the practice room Dana reads the question aloud in your browser’s own voice, with captions, and you answer in the editor beside it, in a design doc with the requirements filled in and a section for each part. It’s free and needs no account. Run the InterviewMind desktop app beside it and it hears the question the way it hears a real call, so you can see what it would show you in the live round.

Practice this question

More system design questions

interviewmind

Clarity under pressure.

Download for macOSWindows

On an Intel Mac? Download for Intel