Delayed jobs
A delayed job runs at a due time and not at once. It needs a stored due time, durable storage and an effect that is safe to repeat. Here 10 million reminders become due at 60 s, none may run early, and each must have exactly 1 effect.
See it on the board
The same traffic runs on two boards. The simulator measured both when this page was built.
| Measure | Goal | Jobs run as soon as they arrive | Jobs wait for their due time |
|---|---|---|---|
| Completion time | under 240 s | 100 s Pass | 160 s Pass |
| Duplicates | none | 0 Pass | 0 Pass |
| Lost writes | none | 0 Pass | 0 Pass |
| Monthly cost | 320 USD/mo | 320 USD/mo | |
| Error rate | 0% | 0% | |
| Level rules | none broken | Board is not complete Fail | Pass |
Key numbers
| Number | Value |
|---|---|
| Messages per second, one queue | 20,000 ops/s |
| Default time a claimed job stays hidden | 30 s |
| Default delivery tries | 5 tries |
4 workers · 3 jobs waiting · wait 33 ms
How it works
Some work must wait. A reminder is due tomorrow, a trial ends in 14 days, a retry is due in 5 minutes. A normal queue hands out each job as soon as a worker is free, so a job would run too early.
A delayed job carries a due time. The queue keeps the job and hides it until that time. Then it becomes visible, and a worker can claim it. The job and its due time must be stored on disk. A restart must not lose 10 million reminders.
In the mini board 10 million reminders are accepted and become due at 60 s. Without delay support, the queue hands them out at once, and they run before they are due. With delay on, none run early, and all work completes within four minutes.
A worker can crash after it sent the reminder and before it confirms the job. The queue then offers the job again. So each attempt must use the same key for its effect, and the receiver must ignore the second attempt.
A burst at the due time is also a risk. 10 million jobs at one instant need capacity for them.
In the levels you set the due time on the queue and check that nothing runs early or twice.