A news feed that stays fast at 10 million users

A social app builds each feed when you open it. At 10 million users that is far too slow.

To design a news feed, choose between building feeds when posts are written, which gives fast reads and heavy writes, or when they are read, which is the reverse. Most designs push posts to ordinary followers' feeds, pull posts from very popular accounts at read time, and merge both.

The system today: A social app stores posts and follows in a SQL database. When someone opens the app, the server finds everyone they follow, fetches their recent posts and sorts them. That is fine for the first ten thousand users.

What has to change: The app now has 10 million daily users, some people follow thousands of accounts and a few accounts have millions of followers. Feeds must load in under half a second, and a new post should show up for followers within a few seconds. Design the feed.

Questions to ask first

Where the interviewer digs in

What a strong answer covers

Common mistakes