Cache stampede
See what happens to the database when many cache keys expire at the same moment — and how two small fixes stop it.
How it works
- 1When many keys are cached at the same time with the same expiry, they also expire together. Every request for them misses at once and hits the database.
- 2Jitter gives each key a slightly different expiry, so the misses spread out.
- 3Single-flight lets only one request refresh a key; the rest wait for that result instead of all querying the database.
Read the post: How to build an API for 100,000 requests a second
More demos
All demosQueryLite: a SQL database
A SQL database written from scratch — parser, B+ tree indexes, a query planner, joins and transactions — running live on 22,000 rows in your browser.
Raft consensus, live
The algorithm that keeps etcd and Kubernetes consistent. Five servers elect a leader and replicate a log — crash them and split the network while it runs.
Live collaborative editor
Real-time editing with no server. Three devices share a note — take one offline, edit everywhere, reconnect, and they merge. Open a second tab and it syncs live.