bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/System Design/Design a News Feed
System Design•Design a News Feed

Design a News Feed: Scaling

Design a home timeline (Twitter/Instagram style) that shows recent posts from accounts a user follows.

How to approach it

Scale by following the request path and fixing the first real bottleneck. Reads usually dominate, so caching and replication come first; writes and storage are handled by sharding on a high-cardinality key. Push slow, retryable work onto queues. Add infrastructure only where the numbers justify it.

Scaling decisions

AreaChoice
Fan-outFan-out-on-write for normal users, on-read for celebrities (hybrid)
CacheStore each user timeline as a capped list in Redis
ShardingShard posts by author_id
QueueAsynchronous fan-out via a queue

Why

  • Fan-out: precomputed feeds make reads cheap, but fanning a celebrity post to millions is too expensive
  • Cache: O(1) timeline reads; only keep the most recent N entries
  • Sharding: spreads write load and keeps an author’s posts together
  • Queue: keeps publish latency low and absorbs bursts

Previous

Design a News Feed: High-Level Architecture

Next

Design a News Feed: Deep Dive