Back to System Design
System Design
News feed
Senior level · full staged walkthrough
Senior
Architecture
SeniorServiceAsyncDataEdge
Solution, step by step
- 1
Functional requirements
- Personalized home timeline
- Show posts from followed accounts
- Rank by relevance/recency
- Handle celebrity (high-fan-out) accounts
- 2
Non-functional requirements
- Feed read latency < 200ms p99
- Freshness within seconds–minutes
- Read-heavy; eventual consistency acceptable
- Scale to hundreds of millions of users
- 3
Capacity & estimation
- 300M DAU, ~10 feed loads/day → ~3B reads/day ≈ 35K reads/s avg
- Avg user follows ~300; celebrities followed by tens of millions
- Posts/day ~500M; metadata ~1 KB → ~500 GB/day
- Per-user feed cache of top ~500 entries
- 4
Preliminary design
- Fan-out-on-write: push new posts into follower feed lists
- Serve feeds from a precomputed per-user store
- Rank before returning
- 5
Final architecture
- Hybrid fan-out: push for normal users, pull-on-read for celebrities
- Per-user feed store (Redis/Cassandra) holding ranked post IDs
- Ranking service scoring candidates with features at read time
- Hydration service joins post IDs → full content from a cache
- Async workers + Kafka for fan-out; backfill jobs for new follows
Interview Q&A (9)
A hybrid: push posts into follower feeds for normal users (fast reads), but pull-on-read for celebrities to avoid writing to tens of millions of feeds.
Key components
- Post service
- Feed store (per-user lists)
- Fan-out workers
- Ranking service
- Cache
Bottlenecks & how to address them
- Celebrity write amplification → pull-on-read
- Ranking cost at read time → precompute candidate features
- Cache misses → multi-tier cache
Tradeoffs to articulate
- Write amplification vs read latency
- Freshness vs cost
- Precompute vs on-the-fly ranking
Where this content comes from
For full transparency, this content is curated and verified from these sources:
Published architecture case studiesCompany engineering blogsOppZen design rubric library