Course map

Project 11

Distributed job scheduler

Scheduling, background work

Start after Part 8

Key topics 121, 133, 137

Architecture Services

Brief

Cron as a service: register one-off and recurring jobs, execute them on time across a worker fleet, with retries, timeouts, concurrency limits, job history, and manual controls.

Targets

1M scheduled jobs · 10k executions/min · a due job runs exactly once per occurrence (none missed, none duplicated) within 10 s of its time · the scheduler survives node loss.

Must cover

  • Leader election for the scheduling tier (→ 133).
  • Leases with fencing against zombie schedulers (→ 137).
  • Duplicate-run prevention — idempotent dispatch records (→ 116).
  • Recurring jobs and missed-schedule (misfire) policy: skip, fire now, or catch up, per job (P).

Design challenges

  1. Due-job detection (→ 64, 106): polling a time-indexed table vs. an in-memory timing wheel vs. broker delay queues — compared at 1M jobs.
  2. Exactly-one-execution: leader election (→ 133), or partitioned ownership of the job space, or claim-by-atomic-update — with fencing tokens either way (→ 137).
  3. Worker crash mid-job: visibility timeout and redelivery vs. idempotency requirements pushed to job authors — the contract written down (→ 115–116).
  4. Cron-expression computation with timezone and DST correctness (→ 135).
  5. Priority and per-tenant concurrency limits so one tenant cannot starve the fleet (→ 96; tenancy in depth → 211).

Out of scope

Workflow DAGs between jobs (→ 122).

Search the guide