Write → merge
Push for most, pull for the famous
Toggle Normal ↔ Celebrity, then hit World-Cup final in Traffic. Two packets ride step 2 (one per branch); step 5 storms the workers and the metrics flip to the playbook.
1 · Tweet accepted fast
Ingest owns the p99: auth, validate, dedup by client mutation-id, persist. Never waits for media transcode — renders progressively from blurhash.
Test yourself
1. Push or pull?
2. Why store only ids in feed cache?
3. Why never OFFSET?
4. What breaks first at 10×?
10× event
World-Cup-final playbook
First bottleneck: fan-out worker lag during global events. Response — pre-lower thresholds (viral mid-size accounts get promoted to pull within minutes), autoscale workers on lag not CPU, shed WTF/ads mixing first (timelines stay correct, just less monetised), serve stale-while-revalidate past 30s lag. Next: home-zset RAM (800→400 cap, 7d→3d TTL for dormant) and reverse-edge reads (precomputed follower-shard snapshots).
Two systems, not one
Home timeline ≠ user timeline
| Home timeline | User timeline | |
|---|---|---|
| Query | Best of my graph (ranked, mixed) | Everything by author X (chronological) |
| Fan-out | Hybrid push + celebrity pull | None — pure pull |
| Cache | Per-viewer Redis zset (private) | Per-author head-cache + CDN (public) |
| Cost | Viewer × sources | Author × readers (CDN absorbs) |
Say it: "user timeline is a cacheable archive; home timeline is a per-viewer computation — different SLOs, different stores." Deletes tombstone then scrub (~1 min) + purge CDN keys. Media never blocks accept: presigned direct upload, async transcode, blurhash placeholder first.
Say it in the room
Interview one-liners
- Q: News Feed vs Twitter? / A: Same hybrid core + dynamic thresholds, early-rank, split home/user timelines.
- Q: What breaks first at the final? / A: Fan-out lag — lower thresholds, lag-scale, shed ads/WTF.
- Q: Why doesn't post wait for video? / A: Metadata persists + enqueues; media renders progressively.
Full write-up: Twitter Timeline case note · Prerequisite: News Feed case · Theory: Stream Processing, Cache Patterns · ← Back to all playgrounds · Pro unlocks News Feed, WhatsApp, YouTube + mock-interview mode.