Background Jobs & Queues

Work that does not belong in the request path: deciding what to defer, the queue lifecycle from enqueue to dead-letter, and what happens when producers outrun consumers.

Background Jobs

Work that outlives the request that asked for it — and the four guarantees you give up to move it there.

Q · What does moving work out of the request path actually change, beyond making the response faster?
Request or Background?

Five questions that decide where work runs — and the reminder that deferring is a cost, not a default.

Q · How do I decide whether this piece of work belongs in the request or in a queue?
Job Queues

Enqueue, claim, process, ack, retry, dead-letter — the six-step lifecycle every queue implements, however it spells them.

Q · What happens to a message between being enqueued and being finished with, and which step is the one that loses work?
Queue Semantics

Ordering, duplicates, retries, visibility timeouts and poison messages — the five properties that differ between every broker you will use.

Q · What does my queue actually guarantee about order and delivery, and what is my code responsible for instead?
Job Idempotency

Delivery will repeat, so the effect must not. How to make a worker safe to run twice, including concurrently.

Q · The same message is delivered twice. How do I guarantee the effect happens once?
Scheduled Jobs

Cron in a single process is a timer. Cron on three instances is three timers, and the job runs three times.

Q · How does recurring work run exactly once when several identical instances are all convinced it is their turn?
Dead-Letter Queues

Somewhere for work that will never succeed, so that one poison message cannot consume the fleet — and a human who is expected to look.

Q · What happens to a message that fails every time, and who finds out?
Backpressure

When producers outrun consumers, something has to give. Backpressure is choosing what, instead of letting memory choose for you.

Q · Work is arriving faster than it can be processed. What should the system do about it?
Worker Scaling

More workers help until the shared dependency saturates, at which point they make everything worse — including the requests still in the path.

Q · How many workers should there be, what signal decides that, and when does adding more stop helping?
Queue Backlog

The queue is growing. Four possible causes, and the recovery that is right for one of them makes two of the others worse.

Q · The backlog is climbing. What is actually wrong, and what should I do in the next ten minutes?