News Feed diagram template

Fan-out on write for most users and fan-out on read for celebrities, behind a feed cache.

News Feed architecture diagramOpen in ArchBoard

Builds a new scene in your browser. Your existing scenes are not touched.

About this design

The news feed problem is a trade between write cost and read latency. Pushing every new post into each follower's precomputed feed makes reads instant, but a user with ten million followers turns one post into ten million writes. This template shows the hybrid most real systems adopt: ordinary accounts fan out on write through a queue and workers that fill per-user feed lists in Redis, while very popular accounts are merged in at read time. A graph store answers who follows whom, a post service owns the canonical content, and a ranking step orders what the user finally sees. Media is served through a CDN and never passes through the feed path. Use it to discuss pagination with cursors, cache warming for returning users, and how to backfill a feed when someone follows a new account.

Diagram as text

This is the source of the diagram, in the ArchBoard diagram DSL. Paste it into Tools, Diagram from text to rebuild or change it.

title "News feed"
direction LR
mobile "App" -> gateway "API gateway" -> service feed "Feed service"
gateway -> service post "Post service" -> db postgres "Posts DB"
post -> queue kafka "Fan-out queue" -> worker fan "Fan-out workers"
fan -> db neo4j "Social graph"
fan -> cache redis "Feed cache"
feed -> feed-cache
feed -> service rank "Ranking"
cdn "Media CDN" -> storage s3 "Media"

Related guides

More interview classics templates