Problem
Design the News Feed system that ranks and delivers posts to billions of users with sub-second latency.
Requirements
Functional:
- Generate a personalized feed per user
- Support posting, likes, comments fan-out
- Rank by relevance, not just recency
- Real-time updates for active users
Non-functional:
- 2B+ users, millions of posts/sec
- p99 feed load < 1s
- High availability
Discussion points
- Fan-out-on-write vs fan-out-on-read (hybrid for celebrities)
- Feed ranking: candidate generation -> ranking model
- Caching layers and pagination
- Handling the 'thundering herd' for viral posts
- Push vs pull for real-time delivery