Learning on Web Dev Open is free for all.

Interview Prep · System DesignDesign a distributed job scheduler
← System Design

Design a distributed job scheduler

Hard45 minFree, no account

At-least-once delivery, a worker that dies mid-job, and a cron that must not fire twice.


The question

Design a service other teams use to run background jobs: one-off tasks, delayed tasks, and recurring schedules.

Say what happens when a worker dies halfway through.

Functional
  • Enqueue a job to run now, at a time, or on a cron schedule.
  • Retries with backoff, and a dead-letter queue.
  • Cancel a scheduled job; see a job's status.
  • Priorities, so a slow low-priority queue cannot starve urgent work.
Non-functional
  • 100k jobs/sec enqueued; 1M scheduled in the future at any time.
  • A job must never be silently lost.
  • A cron must fire once per period even with many scheduler instances.
45:00Commit to an answer before you open the solution. Reading it first teaches you to recognise good answers, which is not the skill being tested.

Stuck?

0 of 3 hints taken

The worked solution

written by a person · not a grade

Score yourself

0 of 5 marked
  • Separated due-now from scheduled-later with a reason25
  • Leases with heartbeat extension, and at-least-once stated honestly25
  • Pushed idempotency to handlers as an explicit contract15
  • Solved cron deduplication with a conditional write20
  • Addressed fairness and starvation15

We run no AI here and nothing on this page grades you. The score is yours, and the useful number is the one you get on the same problem a month from now, cold.

kept in this browser only