System Design
6. Distributed Systems FundamentalsAnimated
Distributed Locking
A lock that works across machines.
The idea
Implemented with a store such as Redis or ZooKeeper, with leases that expire.
Watch it work
Press play, pause, or step through. Some animations have settings you can change.
- current message
- earlier
- failure or attack
A asks for the lock with a time-limited lease.
- step:
- 1/7
- from:
- Client A
- to:
- Lock service
1/7
Time runs downward. Solid arrows are requests, dashed arrows are replies.
Step by step
- 1Try to acquire with a unique token
- 2Receive a lease
- 3Do the work
- 4Release
Where it is used
Preventing duplicate work.
Watch out for
Expired leases and pauses need fencing tokens.