singleflight
A technique that merges many simultaneous identical requests into one, so only one does the work and they all share its result.
In more detail
When a hot cache key expires, singleflight lets a single database query refill it instead of thousands. The name comes from the Go library that popularised it.
Related terms
- thundering herd — A flood of requests that arrives at once when many clients react to the same event, such as all retrying after an outage.
- mutex — A lock that lets only one piece of code at a time run a critical section or do a particular piece of work.
- cache — A store of earlier answers kept close to where they are needed so they can be reused instead of fetched or computed again.
Taught in
- Distributed Cache Invalidation: Redis & Tagged Purging — Production Full-Stack Engineering