Distributed systemsleader leaselock leaselease ttl

Lease

Definition

A lease is a time-bounded grant: the holder may act (hold a lock, lead, use a credential) until the lease expires, and must renew it before then to keep the right.

In practice

Leases solve the crashed-holder problem: if a lock owner dies, the lock frees itself when the lease runs out instead of staying held forever. Leader leases let a leader serve linearizable reads locally while followers promise not to elect anyone else, and secrets managers attach leases to dynamic credentials so they expire and can be revoked.

A lease depends on time, so clock drift and process pauses can make a holder believe it still owns a lease that has already expired. Keep a safety margin, renew well before expiry, and pair leases with fencing tokens when correctness matters. Short leases recover faster after a crash; long leases survive longer outages of the lease service.

Example

A scheduler instance holds the cron-leader lease for 15 seconds and renews it every 5; if it crashes, another instance takes over within about 15 seconds.