Skip to content
System Design Lab
Case Studies

Design a News Feed

Show each user the latest posts from everyone they follow: fan-out on read is slow to load, fan-out on write melts down when a celebrity posts, and the hybrid most large networks use gets the best of both.

Advanced 4 min read· Updated 2026-11-18

What you will learn

  • Compare fan-out on read (pull) and fan-out on write (push).
  • See why accounts with millions of followers break push.
  • Design the hybrid model and the feed storage behind it.
  • Rank, paginate and cache feeds.

Before you start

Requirements

  • Functional: users post; each user's home feed shows recent posts from accounts they follow, newest (or highest-ranked) first, paginated.
  • Non-functional: loading a feed is fast (p99 < 300 ms); new posts appear for followers within seconds; reads vastly outnumber writes.
  • Skew: most accounts have a few hundred followers; a few have tens of millions.

Back-of-the-envelope estimates

QuantityAssumptionResult
Feed loads300 M daily users × 10 loads~35,000 reads/s
Posts300 M × 0.5 posts~1,700 posts/s
Fan-out (push)Average 200 followers~350,000 feed inserts/s
Celebrity post50 M followers50 M inserts for a single post

Evolve the design

Stage 1 of 3

Fan-out on read

Current architecture
Loading a feed fetches recent posts from every followed account and merges them.
Limitation
Read cost grows with the number of accounts followed — and reads are the hot path.
Bottleneck
Read workers: 200 lookups per feed load saturate the service.
Improvement
Do the work once at write time instead of on every read.
Performance impact
Most feed loads time out.
Complexity & operational cost
Cheap writes, very expensive reads.
Trade-off
Always fresh, but the slow operation is the frequent one.
Loading simulation…

Feed storage

Precomputed feeds as capped sorted sets in Redis
# Fan-out on write: add the post to each follower's feed, keep only the newest 800 ids.
ZADD feed:{user_42} 1763459000 post:9001
ZREMRANGEBYRANK feed:{user_42} 0 -801

# Read: newest 20 ids, then batch-fetch post bodies (cached) and merge in celebrity posts.
ZREVRANGEBYSCORE feed:{user_42} +inf -inf LIMIT 0 20
  • Store ids, not posts: feeds hold post ids; post bodies live once in a post store and cache.
  • Paginate with a cursor (score/time of the last item), not offsets — feeds change while you scroll.
  • Skip inactive users during fan-out and rebuild their feed on next login.
  • Ranking happens at read time over a candidate set (recent ids + celebrity posts + recommendations).

Trade-offs

BenefitsCosts
PullNo write amplification; always fresh.Expensive reads on the hottest path.
PushReads are a single lookup.Write amplification and huge backlogs for big accounts.
HybridBounded fan-out with fast reads.More complexity and a threshold to tune.

Interview checklist

  • Compute the read/write ratio and follower skew first.
  • Explain pull vs push, then the celebrity problem, then hybrid.
  • Describe feed storage (ids in sorted sets), post store and caches.
  • Mention cursor pagination, ranking and handling inactive users.

Further reading

Related topics