Skip to content
Preptima
hardDesignCase StudySeniorStaff

Design a distributed job scheduler that runs every job once, and on time, even when workers die.

A distributed job scheduler cannot promise exactly-once execution when workers die mid-job, so it promises at-least-once with idempotent jobs. Materialise each firing as a run row, claim it with a lease and heartbeats, judge time by one clock, and key side effects on job id plus scheduled time.

5 min readUpdated 2026-10-10Target archetype: Big Tech

Answer

Short answer

Exactly once is not available. A job scheduler whose workers can die mid-job must choose between possibly skipping a run and possibly repeating one, and repeating is the safer error. So the design is at-least-once execution plus idempotent jobs: each firing becomes a run row, a worker claims it with a time-limited lease and heartbeats, a dead worker's lease expires and another worker retries, and the job keys its side effects on job id plus scheduled time so the retry is harmless.

Was this answer helpful?

Likely follow-ups

  • A job's lease expires while its original worker is stuck in a long garbage-collection pause. Walk through what both workers do next.
  • How would you move a partition of jobs from one scheduler node to another without a firing being lost or doubled?
  • A recurring job takes longer than its own interval. Does the next run start, wait, or get skipped, and who decides?
  • How would you let a job author see why their job ran four minutes late last Tuesday?

Related questions