techdiagrams.net
← All templates

Social news feed

The hybrid feed: fan-out-on-write materializes timelines for normal users, celebrities are merged at read time, and a stampede-protected cache keeps hot feeds cheap.

Open in editor — free, no login Download JSON
WRITE PATH — FAN-OUT-ON-WRITEREAD PATH — MERGE AT READGET /feedhot pathprecomputed (normal authors)pull celebrities at read timePOST /postappend ×N followersfollowers of authormentionsPost Servicewrites go herePostCreatedat-least-onceFanout Workersskip authors > 10k followersTimelinesper-user · materializedReaderopens the appFeed APIread + write edgeFeed Buildermerge write-path + read-pathFeed Cachehot feeds · early expiryNotificationsmentions · DMsPosts Storecelebrity posts read hereSocial Graphwho follows whomthe hybrid rule:followers < 10k → write-time fanoutfollowers ≥ 10k → read-time pullone knob, both failure modes avoided

What this design does

Pure fan-out-on-write dies the day someone gets 40M followers — one post becomes 40M timeline writes. Pure fan-out-on-read dies for everyone else — every feed load recomputes the world. Real feeds are hybrid: normal authors fan out to materialized per-user timelines at write time; celebrity posts are pulled and merged at read time; and a cache with stampede protection stands in front of it all so a viral moment doesn't become a database incident.

The patterns it composes

Import it, attach your own numbers, and verify the design against failures — or read the engineering notes.