Inside a distributed task scheduler
hard 30 minHow a scheduler finds due tasks, gives each to one worker, survives crashes at every step and grows: a store that is the truth, a claim with a lease, tokens that stop late workers, and partitions.
Where it shows up
The same pattern appears across everyday software.
Amazon SQS
A received message is hidden for the visibility timeout, 30 seconds by default, and returns if it is not deleted. After a set number of receives it moves to a dead-letter queue.
Google's cron
The SRE book describes replicas that record the start and end of every launch with Paxos, so that a new leader knows what was already started.
Kubernetes CronJob
A controller creates Job objects from schedules. The documentation warns that a run may happen twice or not at all, so jobs should be idempotent.
PostgreSQL as a queue
`FOR UPDATE SKIP LOCKED` gives different rows to different workers. The manual names queue-like tables with several consumers as its use.
Celery beat
One process sends periodic tasks to workers. Its documentation says that only a single scheduler may run for a schedule, or tasks are duplicated.
EventBridge Scheduler
A managed scheduler with at-least-once delivery, retries and flexible time windows. The documentation of SQS points to it for delays longer than 15 minutes.