Design a News Feed – Design

10 min · Step: design

Design a News Feed – Design

For a read-heavy feed at moderate scale (e.g., 1M DAU):

High-Level Architecture

  1. Post service: Creates and stores posts (DB: PostgreSQL or similar).

  2. Graph service: Tracks follow relationships.

  3. Feed service: Builds timelines. Options:

    • Pull (fan-out on read): Fetch posts from followed users on each request. Simple, but slow for heavy follow graphs.
    • Push (fan-out on write): Precompute feed per user when new posts arrive. Fast reads, expensive writes.
  4. Cache: Redis for hot feeds.

Inline Check 1

When is fan-out on read (pull) acceptable?

<!-- quiz-candidate: true -->