Infrastructure & Integrations
Queues and background jobs: answer now, do the slow work where you can see it
What goes in a queue
Rules every job follows
01
Safe to run twice
Same job, same result
A job can be picked up twice after a crash. The invoice is still created once and the text still sent once.
02
Retries that wait longer each time
A minute, five, half an hour
So a struggling service gets room to recover instead of being hit harder.
03
A time limit
Stuck isn't the same as slow
A job that runs past its limit is stopped and retried, not left running forever.
04
Visible
Waiting, running, done, failed
Anyone responsible can see what's queued, how long it's waited and what failed, without asking a developer.
05
A place for what can't finish
With the reason, for a person
After the last retry, the job goes to a list someone checks, with what it tried and why it stopped.
Three ways a job fails
INV-2301 → accounting
- failed
Attempt 1
accounting unavailable
- done
Wait 1 minute
- done
Attempt 2
invoice created in accounting
Nobody had to notice. The job log shows both attempts.
text · C-0412 reminder
- failed
Attempt 1
number not in service
- skipped
Retries
this answer won't change by retrying
- with a person
Office list
call C-0412 for a new number
A retry wouldn't help, so it went straight to a person, with the reason.
Plan renewal · C-0731
- done
Picked up
by a worker
- failed
Worker restarted
during a release, partway through
- done
Picked up again
by another worker, after the time limit
- done
Already charged?
checked first: no; charged once
The renewal finished once, even though it started twice.
Where the queue sits
In
Out
Worth adding when people wait on work they don't need to see
Good fit
- Screens hang while something is sent or processed.
- Your software depends on services that are sometimes down.
- Failed sends and syncs are found by customers, not staff.
Not the right fit
- Everything finishes quickly and nothing depends on another service. A queue adds parts to run for no gain.
- The work is a business process people follow. That's workflow automation.
Questions about queues and background jobs
Does every app need a queue?
No. If everything finishes quickly and nothing depends on another service, ordinary code is simpler and safer. A queue earns its place when work is slow, unreliable or happens in large batches.
What stops a job running twice?
Each job carries a key, and the step that matters checks it first: if this invoice or this charge already exists, it isn't created again.
Who sees failed jobs?
Whoever you choose. Usually the office sees the ones they can fix, like a wrong phone number, and the developer sees the rest.
How is this different from workflow automation?
Workflow automation runs your business processes, often with people in the steps. Background jobs are the software's own housekeeping: sending, resizing, syncing. Many systems use both.