← Lessons

quiz vs the machine

Gold1380

System Design

Lease Based Locking

Time bound locks that auto expire so a crashed holder cannot block forever.

4 min read · core · beat Gold to climb

The problem with plain locks

If a client acquires a lock and then crashes, a simple lock stays held forever and no one else can proceed. Distributed systems cannot tell a crashed client from a slow one, so they need a time based escape.

Leases

A lease is a lock with an expiry. The holder gets it for a fixed duration and must renew it before it expires to keep holding it.

  • If the holder keeps renewing, it retains the lease.
  • If it crashes or stalls, the lease expires and the service frees it.

The renewal race

A holder should renew well before expiry to survive a slow network. If a renewal is late, the holder must assume it lost the lease and stop acting on it, because someone else may already have acquired it.

Key idea

A lease is a self expiring lock: holders renew to keep it, and a crashed holder automatically releases it, preventing permanent deadlock.

Check yourself

Answer to earn rating on the learn ladder.

1. What problem does a lease solve compared to a plain lock?

2. Why must a holder stop acting if a renewal is late?