RSS Amplifier

Hands-on System Design with Java Spring Boot · Aug 13, 2026

Week 4: Leader Election & Reliable Execution (Days 16–20)

0
Sign in to vote or save

System Design With Java · Hands-on System Design with Java Spring Boot

When Uber dispatches surge-pricing jobs, when Netflix refreshes CDN caches, or when your bank runs end-of-day reconciliation, exactly one scheduler instance must decide what runs and when. Run the same cron on every pod and you double-charge customers. Run none and reports never ship.

The fix is not “turn off scheduling on followers.” You need an explicit leader election contract, lease-based heartbeats, automatic failover, coordination primitives, and idempotent execution so retries never corrupt state.

In a horizontally scaled cluster, one node holds a lease in shared storage. The lease has an expiry timestamp. The leader renews it on a heartbeat interval (typically one-third of lease duration). Followers observe an unexpired lease owned by someone else and stay idle.

This is how Google’s Chubby-inspired systems, Kubernetes lease objects, and JDBC-backed Spring schedulers keep one brain in charge.

PostgreSQL stores a cluster_leadership row per service. Acquisition uses optimistic versioning plus conditional updates:

  • Renew: update only if you still own a non-expired lease

  • Takeover: update only if the lease is expired

  • Failover: force-expire a stale leader after health checks fail

Read the original on javatsc.substack.com

Comments

Nothing yet. Say the first thing.

    Sign in to join the conversation.