Design a news feed like Facebook's
hard 50 minShow each person the best recent posts from everyone they follow, in a fifth of a second.
Remember it
The few things worth knowing cold, and how to make them stick.
Memory hook
Push small, pull big, rank once, check always.
A paper carrier fills letterboxes for ordinary news. The famous notice hangs once on the wall. A reader takes the paper, looks at the wall, and throws away anything withdrawn.
Cheat sheet
- Reads
- 231K/s, peak 694K
- Posts
- 4,630/s, peak 13,900
- Push / pull
- 2.3M / 116M a second
- Ready feed
- 500 IDs, 10 KB
- All ready feeds
- 25 TB, 50 TB with copies
- Big account limit
- 10,000 followers
- Big accounts in memory
- 2 GB
- Hydration
- 4.6M/s, peak 14M
- Ranking
- 500, 100, 20 in 60 ms
- Hint
- every 10 s at most
Spot it when you see
- A personal list made from many sources.
- Reads far above writes.
- A few producers with enormous audiences.
- Activity logs, timelines, notifications.
Tricks that stick
- Two products: posts × followers, reads × follows.
- 500, 100, 20: gather, score, show.
- Copies travel, permission stays home.
- Durable, answer, deliver.
Do not forget
- Pushing for everyone.
- Synchronous fan-out.
- Cache as permission.
- Offset pages.
- Forgetting hydration.
- Calling a Redis pipeline atomic.