What it provides
A distributed lock service lets many machines agree that only one of them holds a named lock at a time. Systems like ZooKeeper and etcd offer this so that exactly one worker runs a critical section across the whole fleet.
How it works
- A client asks the service to acquire a lock by a name.
- The service grants it only if no one else holds it, backed by a consensus log so all replicas agree.
- The holder later releases the lock, or it expires.
The hard part
The lock service itself must be highly available and consistent. It usually runs as a replicated cluster using Raft or Paxos, so a single node failure does not lose the lock state or grant the same lock twice.
Key idea
A distributed lock service is a consistent, replicated coordinator that grants a named lock to one client at a time so distributed workers avoid stepping on each other.