Design a Job Scheduler
Design a service where teams register jobs and the service runs them on time: “call this endpoint every day at 02:00 in Berlin”, “run this container every 5 minutes”, or “send this reminder once, next Tuesday at 09:30”. Each run is retried if it fails, and owners can see every run’s status and logs, pause a job, or run it now.
The service holds 50 million job definitions and starts 200 million runs a day, from 1-second calls to 6-hour batch tasks. The hard parts are firing every run within a few seconds of its time even while machines fail, never losing a timer, never running one run twice at the same time, and surviving the top of every minute, when far more jobs are due than at any other second because people write 0 * * * *.
Good questions to ask first
Decide what you would assume for each before you look at ours.
- 1What does a job run?
- 2How precise must the start be?
- 3Exactly once?
- 4How long do runs take?
- 5Which schedules?
- 6What if a run fails?
- 7What if the previous run is still going?
- 8Many tenants?
How to spend the 45 minutes
- 5minPart 1: Requirements and scope
- 5minPart 2: Estimates
- 5minPart 3: API
- 15minPart 4: Architecture, stage by stage
- 15minPart 5: Deep dives and trade-offs