Design a News Feed
HardBuild a scalable news feed system that ranks and delivers personalized content in real-time.
Interviewer
Design a News Feed
You're designing the news feed for a social network like Facebook or Twitter. Users follow friends/influencers and see posts in their feed, ranked by relevance. The system must handle high-velocity post ingestion, personalized ranking, and real-time updates as users scroll.
Scale assumptions:
- 500 million daily active users (DAU)
- Average user follows 500 accounts
- 1% of followers post per day (5M posts/day, average)
- Ranking must consider: recency, engagement (likes, comments), follower count, past user interactions
- Feed latency target: <100ms to serve 20 posts
- Retention: feeds computed on-demand (no pre-fan-out due to storage cost)
Derived numbers:
- Post ingestion: 5M posts/day ÷ 10^5 sec ≈ 58 writes/sec average, ~200 peak
- Feed reads: 500M DAU × 3 feed refreshes/day ≈ 17.5M reads/day ≈ 200 reads/sec average, ~1K peak (assuming uniform)
- Candidate generation: per-user feed = scan recent posts from followed accounts (expensive; need index)
- Ranking: score candidate posts (~1K posts per user per day) by ML model (latency-critical)
- Hot users: celebrities with 50M+ followers amplify post reach (fanout bottleneck)
Sign in to start the interview.
The interviewer grades each stage against a hidden rubric and asks a probing follow-up, mirroring a real system design round. Sessions are capped at 30 turns.