← Lessons

quiz vs the machine

Gold1400

System Design

The Distributed Lock Service

A coordination service that hands out mutually exclusive locks across machines.

5 min read · core · beat Gold to climb

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.

Check yourself

Answer to earn rating on the learn ladder.

1. Why is a distributed lock service usually backed by consensus?

2. What is the primary guarantee a lock service offers?