News Feed: Requirements
Posts from friends.
Our next case study is a news feed, like on Facebook, Instagram, or X. You follow people, they post, and you see their posts on your home page.

- You follow people
- They post
- You see a feed
Requirements
Functionally, users publish posts, follow other users, and see a feed of posts from the people they follow, newest or best first. Non functionally, the feed must load fast, under two hundred milliseconds. It can be slightly out of date. A post may take a few seconds to appear. And it must scale to hundreds of millions of users.
Functional
- Publish postsFollow usersSee a feed
Non-functional
- Feed under 200 msA little stale is fineHuge scale
The core problem
The heart of the problem is this. A user follows five hundred people. Building their feed means collecting recent posts from all five hundred, sorting them, and returning the top twenty. Doing that from scratch, on every page load, for millions of users, is far too slow. We need a smarter approach.
| key | value |
|---|---|
| Follows | ~500 people |
| On each load | collect, sort, top 20 |
| From scratch | too slow |
| Need | a smarter approach |
Summary
A news feed shows posts from the people you follow, quickly, at huge scale. Building it from scratch on every load is too slow. Next, the key idea. Fan out.
Key takeaways- Posts from people you follow
- Fast, slightly stale is OK
- Don't build from scratch