EN 中文

System Design Lab

A social news feed lives or dies on the fan-out choice: push posts into every follower at write time, or pull and merge at read time.

Change daily active users, posting rate, average and celebrity follower counts, feed reads, feed size, and ranking cost. The design moves from pull-on-read merges to push fan-out with a feed cache, a hybrid that special-cases celebrities, a ranking pipeline, and finally sharded stores across regions.

Guided walkthrough

Reason about it one step at a time

Normal evolution scenarios

Click left to right for the intended demo path. Each card changes the workload inputs.

Workload

These are inputs, not preset architecture stages.

Recommended shape

Current architecture path
Social news feed architecture diagram Whiteboard-style architecture diagram for a social news feed: clients, edge and API gateway, a fan-out service with feed cache, a post store and follow graph, and ranking plus async workers. Clients Edge / API Fan-out + cache Stores Ranking / async Client post + read API gateway post + feed Feed service assembles feed Fan-out worker push on write Feed cache per-user feeds Post store posts + media Follow graph who follows whom Ranking service scores feed Celebrity merge pull at read
Clients
Client creates posts and loads the home feed timeline
Edge / API
API gateway routes post writes and feed reads to the right services
Feed service serves the home feed, reading the cache and merging extras
Fan-out + cache
Fan-out worker pushes each new post into every follower feed cache
Feed cache holds precomputed feeds so reads are a single cache fetch
Stores
Post store durable store of every post sharded as volume grows
Follow graph follower and followee edges used to compute fan-out targets
Ranking / async
Ranking service scores and reorders feed items by predicted relevance
Celebrity merge merges huge-account posts at read time instead of fanning out

Bottlenecks

Write fan-out amplification

Celebrity fan-out cost

Feed cache memory

Read merge cost

Post write throughput

Why this changes

    Decision tradeoffs

    Fan-out strategy

    Feed cache

    Celebrity special-casing

    Post-store sharding

    Ranking pipeline

    Source-backed rules

    These are the durable system-design claims behind the model. The exact slider thresholds are deliberately labeled as teaching assumptions.

    Verified rule

    Feeds are usually fan-out-on-write, with a hybrid for celebrities

    The canonical write-up precomputes feeds by pushing posts to followers at write time, then special-cases very high-follower accounts by merging their posts at read time.

    System Design Primer
    Verified rule

    Redis backs per-user feed caches as sorted lists

    In-memory sorted structures hold each user feed so a feed read is a single fast range fetch instead of a database join.

    Redis Docs
    Verified rule

    Kafka decouples post writes from heavy fan-out work

    A durable log lets the post write return immediately while fan-out workers consume events and push into follower feeds asynchronously.

    Apache Kafka
    Verified rule

    DynamoDB-style partitioning scales the post and graph stores

    Partitioning posts and follow edges by key spreads storage and write throughput across nodes as the dataset outgrows one machine.

    AWS DynamoDB

    Teaching assumptions

    • Write fan-out is modeled as posts/s times average followers; read fan-out as feed reads/s times followees merged.
    • Single-node fan-out, cache, and store budgets are conservative teaching numbers, not vendor limits.
    • Celebrity hybrid removes the largest accounts from write fan-out and adds a small per-read merge instead.