Step 1: Requirements and estimates
Functional requirements:
- A user can publish a post (text, images).
- A user can follow and unfollow other accounts.
- A user sees a home feed: posts from accounts they follow, newest first (ranking comes later), loaded page by page.
Non-functional requirements:
- The feed opens fast, ideally under 200 ms on the server.
- A new post doesn’t have to appear in every follower’s feed instantly; a few seconds is fine. This is eventual consistency, and it’s what makes the design possible.
- The system must handle celebrities: accounts with tens of millions of followers.
Out of scope unless asked: comments, likes, ads, notifications, search.
Clarify: chronological or ranked feed (ranked changes storage and pagination), feed composition (followed accounts only, or also groups, recommendations, ads), media handling (out of scope: object storage and CDN), freshness target, and whether the feed must be consistent across devices. The key numbers are the read/write ratio and the follower distribution: a power law, where the median account has a few hundred followers and the top accounts have tens of millions. Those two facts decide the fan-out strategy.
Daily active users: 300 million
Feed opens: ~10 per user per day → 3 billion / day ≈ 35,000 / s (peak ~100,000 / s)
Posts: ~0.3 per user per day → 100 million / day ≈ 1,200 / s
Average followers per poster: ~200 (median lower; a few accounts above 10 million)
Fan-out on write: 100 million posts × 200 followers = 20 billion feed inserts / day
≈ 230,000 / s average
Feed cache: keep the latest 500 post ids per active user
300 million × 500 × 8 bytes ≈ 1.2 TB (sharded Redis cluster)
Posts: 100 million / day × ~1 KB ≈ 100 GB / day (media stored separately)- Reads (35,000 per second) far outnumber writes (1,200 per second). We can afford extra work when posting to make reading cheap.
- 20 billion feed inserts a day sounds huge, but each one is just “add post id to a list”, and only ids go into feeds: the posts themselves are stored once.
- 1.2 TB of feed cache fits in a cluster of in-memory servers.
- Post, follow, home feed (chronological then ranked), paginated; posts appear within seconds (eventual consistency).
- ~35k feed reads/s (peak 100k) vs ~1.2k posts/s; read-heavy by ~30–100×.
- Follower counts follow a power law: median hundreds, top accounts tens of millions.
- Feed caches of post ids only: ~500 ids × 300M users ≈ 1.2 TB in sharded Redis.
Check this part
Why is it acceptable for a post to take a few seconds to reach followers' feeds?
Which fact most shapes the fan-out strategy?