Skip to content

Case study: Distributed job scheduler

Design a fault-tolerant distributed job scheduler with sharded time buckets, worker lease heartbeats, fencing tokens, and 00:00 UTC spike control.

35 min9 steps

By the end you can
  • Estimate worker concurrency using Little's law, schedule storage, and the 00:00 UTC top-of-the-hour cron spike
  • Design a two-tier storage and ready-queue architecture that finds due jobs without full-table scans
  • Use lease heartbeats, visibility timeouts, and monotonic fencing tokens (`leaseEpoch`) to prevent duplicate side effects from zombie workers
  • Predict how the scheduler handles worker crashes, midnight cron surges, poison-pill jobs, and database leader failover

Pin down what 'reliable scheduling' means

Features

  • Delayed/cron jobs; cancel, inspect, history, retries, timeouts, DLQ

Targets

  • Dispatch within about 1 s; survive midnight bursts

Safety

  • At-least-once dispatch; downstream fencing + execution idempotency

Why can't a distributed job scheduler guarantee 'pure at-most-once AND never-lost' execution without cooperation from the downstream resource?

Answer this step to continue.