medium

Design a Distributed Locking System

Develop a highly available, reliable, and scalable distributed locking service that enables distributed applications to acquire, hold, and release locks on shared resources across a distributed system. The service should prevent deadlocks, minimize latency, and ensure fairness in lock acquisition.

Suggested time: 45 minutes

Loading the workspace...

About this problem

You build a distributed system where two services each run a cron job that processes payments. Both fire at midnight. Without coordination, both process the same batch: customers get charged twice. A distributed lock solves this: one service acquires the lock, processes payments, and releases it. The other waits or skips. The challenge is not building the lock. The real challenge is making the lock survive server crashes, network partitions, and clock drift.

Key challenges the editorial covers

Learn from other designs

Related problems

Guides