Design a News Feed
Design the home feed of a social network. People follow other people and pages; when someone posts text, photos or a link, the post shows up in their followers’ feeds. Opening the app shows the feed, newest and most relevant first, and scrolling loads more. People also like and delete posts, and follow and unfollow accounts.
There are 300 million daily users who open their feed 10 times a day, 100,000 feed loads a second at peak, and 150 million new posts a day. The average account has 200 followers, but some have 50 million. Feeds must load in under 200 ms, and a new post should reach followers within seconds. The hard part is the mismatch: one post must reach many feeds, and one feed must gather posts from many accounts, and celebrities make either direction explode.
Good questions to ask first
Decide what you would assume for each before you look at ours.
- 1How many users and reads?
- 2How many posts?
- 3How many followers?
- 4Chronological or ranked?
- 5How fast must a post appear?
- 6How far back does the feed go?
- 7Media?
- 8Ads, groups and comments?
How to spend the 45 minutes
- 5minPart 1: Requirements: ranked or not, freshness, scale
- 5minPart 2: Estimates: reads vs posts, follower skew
- 5minPart 3: API
- 15minPart 4: Architecture, stage by stage
- 15minPart 5: Deep dives: fan-out, hydration, ranking, deletes