Distributed Lock — Notes
Functional
- Acquire / renew / release on a string key.
- Fencing token returned on acquire.
- Watch for lock holder changes.
Non-functional
- p99 acquire < 10 ms.
- Safety > liveness for correctness-critical use.
Use cases
- Leader election for singleton jobs.
- Cron deduplication.
- Critical sections / serialized resource access.
Trade-offs
- etcd / ZK = safe + slower; Redis = fast + caveats.
- Always design for "I think I have the lock but I don't" — fencing token validation at the resource side.
Refs
- "How to do distributed locking" — Martin Kleppmann.
- etcd, ZooKeeper, Consul docs.
- Redlock specification + critiques.