HARDDistributed Systems

Design a Distributed Lock Service

Design a distributed lock service like Apache ZooKeeper or etcd for coordinating distributed systems.

Estimated Time: 45 minutes
#Consensus#Distributed Locking#Leader Election#Fault Tolerance
Solution Overview

Implement consensus protocol (Raft/Paxos) for lock state. Handle split-brain scenarios. Provide lease-based locks with TTL.

Hints to Get Started
1

Why is distributed locking hard?

2

Split-brain scenarios

3

Lock vs lease semantics

Consensus

Raft for leader election and log replication

Lock Types
  • Exclusive locks
  • Read-write locks
  • Semaphores
Failure Handling

Fencing tokens, lease expiration