SD-15 · Back to the write-up
Design a News Feed
Push post ids into cached timelines for most authors, pull celebrities at read time, then hydrate and rank from a post cache.
Follow a request
Publish a post
Load the feed
A celebrity posts
A user comes back
Delete a post
Clients
Gateway and graph
Read and write
Feeds and fan-out
Media CDNPhotos, video
ClientsApps and web
Social graphFollowers
API gatewayAuth + limits
Post serviceCreate, delete
Feed serviceGather, rank
Post cachePosts by id
Post store64 shards
Feed cache300 ids per user
Fan-out workersPush ids
Post eventsChange stream
The numbers, at a glance
1 post ≈ 1,740/s20 feed loads ≈ 35,000/s
3M/sPush all
1M/sSkip celebs
600K/s+ skip inactive
0.02% celebrities99.98% pushed as usual
A feed load, in order
Timeline read, celebrity pull, hydration and ranking. Fan-out happened earlier, when each post was written.
Client
API gateway
Feed service
Feed cache
Social graph
Post cache
Post store
1 GET /v1/feed
2 feed for user
3 read 300 ids
4 ids
5 celebs followed
6 4 accounts
7 recent ids + multi-get ≈ 500
8 load 5% misses
9 posts
10 post objects
11 20 ranked + cursor
12 200 feed
RequestResponseAsync, does not block
Push, pull or both
The decision this question is really about.
GET /v1/feed
posts of 200 accounts
merge by time, p99 over 200 ms
+ Cheap writes.− 200 queries per feed load.
POST
id → every follower’s timeline
3M writes/s at peak
+ One read per feed.− 50M writes for one celebrity post.
Push: authors under 100K followersPull: celebrities
Merge + hydrate + rank
+ Fast reads, bounded writes.− Two paths to merge.
How it grows
Add a box only when a number forces you to. Highlighted boxes are new at each stage.
Clients
API gateway
Feed servicePost service
Social graphPost database
Clients
API gateway
Feed servicePost service
Feed cachePost storePost events
Social graphFan-out workers
Clients
API gateway
Feed service + celebrity pullPost service
Feed cachePost cachePost store
Social graphFan-out workersPost events
ClientsMedia CDN
API gateway
Feed service + rankingPost service
Feed cachePost cachePost store
Social graphFan-out workersPost events
Was this walkthrough useful?Your vote tells us what to improve next.