Cache
A fast in-memory copy of popular data (e.g. Redis). Cache-aside: check the cache first; on a miss, read the database and save the result in the cache.
See it in action
These lessons put cache to work. Read one, then play it and watch what happens without it.
- Add a cache: 20,000 req/s at peak, 95% of them reads, and the machine budget is $1,800/month. Adding more and more replicas is…
- Survive a crash: Launch day: 10,500 requests per second. Machines die all the time. Any single one may crash, and once failover ends,…
- Go worldwide: Half your users are now outside the US: 30% in Europe and 20% in Asia. A read from Mumbai to Virginia takes about 190…
- Ask before you build: An interviewer says: design a link shortener. You ask, and learn it gets 5,000 req/s, and people open links about 99…
- Add a machine, keep your data: Traffic has reached 9,000 req/s and your one cache needs company. Last time you added a machine, nearly every key…
- Count the nines: Sales wants to promise customers 99.9% uptime, which people call three nines. Your design has one load balancer, one…
- The cache that took down the database: 12,000 req/s, and the cache answers 4 in 5 reads, so the database is calm. Then the home page's cached answers all…
- The PDF that ate the quota: Your app answers questions about documents: 2,000 req/s, and 1 in 200 asks the model something, 10 calls a second.…