lock
A marker that gives one worker exclusive access to a resource until it releases it.
In more detail
Locks prevent races but make others wait, and under heavy contention lock waits dominate latency. A per key lock is how single flight lets only one request refill a cache entry.
Related terms
- row lock — A database lock on one row that makes other transactions wait before changing it.
- distributed-lease — A lock that expires automatically after a set time unless the holder renews it.
- contention — Many operations competing for the same resource, such as the same row or lock, at the same time.
- single flight — Letting only one request fetch a missing value while other requests for the same key wait for its result.
Taught in
- The Storage Decision: Key Value, Search And Blob — Scalable System Design & Distributed Architecture
- Cache Invalidation And The Three Hard Cases — Scalable System Design & Distributed Architecture
- Worked Design One: Ticket Booking, Correctness First — Scalable System Design & Distributed Architecture
- Worked Design One: Scaling The Ticket Booking System — Scalable System Design & Distributed Architecture