System 12.8 — News Feed
In one line
The read-path emphasis of Twitter: ranking, dedupe, pagination and the per-user inbox model.
Think of it like this
Your Instagram or LinkedIn home page: a blended, ranked stream pulled from everyone you follow, refreshed constantly, and never showing you the exact same post twice even as you keep scrolling.
Key ideas
- 01
Feed = merge of followings' recent posts, ranked by score (recency + engagement + network), deduped, paginated.
- 02
Two construction views again: pull-merge (N followings, small reads) vs push-inbox (precomputed) — hybrid as before.
- 03
Ranking on push: rank at read time over a small inbox horizon (last 500 events), not a global sort.
- 04
Pagination: cursor-based on (time, id) — ORDER BY created DESC turns into WHERE ts < cursor — no offsets.
- 05
Caching hierarchy: hottest feeds in memory (Caffeine/Redis), next in Redis Cluster, DB as fallback (usual L1/L2).
- 06
Data freshness: eventual consistency; the feed may miss a just-posted item by seconds — say it.
- 07
Existence as a feed-system: the same design serves LinkedIn/Reddit/IG home — naming that transfers is a senior signal.
Code & diagrams
Same hybrid fan-out as Twitter, with a ranking step inserted right before the response leaves the building.
Explain without notes
Why is cursor pagination required at feed scale — what breaks with page=5&size=20?
Practice
Design ranking score (time decay + engagement) and the inbox horizon size with reasoning.
Trade-offs
- ↔
Push gives fast reads + write cost; pulling celebrities on read bounds the write burst. The hybrid is the interview.
Run it in production
You've designed it. Now build, operate, and break the same idea hands-on in the DevOps courses:
Completion checklist
I can design a feed with hybrid construction, ranking, cursor pagination, and cache hierarchy.