Skip to content
SD-23 · JOB SCHEDULER · INTERACTIVE

Break it.
Then fix it.

Raise the number of jobs due each second, watch the top of the minute flatten your scheduler, and add the parts a real scheduler needs. Every switch is a decision you would defend in an interview.

CHALLENGEStart 20K runs/s on average with p99 start delay under 5 s, no missed runs and no run executed twice.
StatusDOWNAt 5K runs per second
Start delay p9960+ sTarget under 5 s after due
Missed runs88.9%Runs dropped or skipped
Double runspossibleA retry can run a job again
Monthly cost$47,160572 workers
Due jobsLIVE
5.0K runs/s · 40K/s at :00
traffic source
SchedulerDOWN
Enqueues due runs
40K / 15K runs/s
Job storeDOWN
Full scan every second
80K writes/s + scan
Run queueOK
Buffers the spikes
40K runs/s in
Workers × 572OK
Autoscaled
40K / 57K runs/s
Job targetsRAN TWICE
Your code and endpoints
retries run again
Every tick scans every job. Finding due jobs reads all 18M rows each second. Index jobs by `next_run_at` so a tick reads only the jobs that are due.
8×Peak at the top of the minutePeople write 0 * * * *. Jitter over 30 seconds cuts it to 2×.
2Writes per runClaim and finish. At peak this, not the scan, fills one database.
16Shards, one lease eachEach scheduler owns its shard; a fencing token stops a stale owner.
≥ 1Runs per due timeAt-least-once plus an idempotency key is how “exactly once” is really built.
Want the reasoning behind every switch?Visual walkthroughFull write-up
Was this lab useful?Your vote tells us what to improve next.