Guides
The shape of a reliable job
Most background jobs do not fail loudly. They disappear, run twice, or finish in the wrong order. This guide is about the small set of rules that keep a queue boring.
Why background jobs fail quietly
A job leaves the request cycle and enters a world with no user waiting for it. When it fails, nobody is looking at the screen. The only evidence is a log line, a queue depth, or a customer asking why the invoice never arrived.
Reliability is not a library you add at the end. It comes from how the job is shaped: what it records, what it repeats, and what happens when the process dies halfway through.
The shape of a reliable job
Every job has four properties: an identity, a payload, a handler, and a deadline. If any of them are missing, the queue is guessing.
Give each job a stable ID before it is enqueued. That ID is what lets a retry replace a duplicate instead of creating one, and what makes the job findable when someone asks what happened.
Choose a queue you can inspect
A queue you cannot read is a queue you cannot debug. You want to see waiting jobs, active jobs, failed jobs, and the age of the oldest item in each of those groups.
Prefer a system that stores jobs as rows or documents you can query. Dashboards are useful, but the ability to run an ordinary query against the backlog is what saves you at three in the morning.
Make every job idempotent
A job will run twice. The network will time out after the work succeeded, the worker will be replaced, or a retry will fire before the first attempt finishes.
Design the handler so the same job applied twice produces the same state: upsert instead of insert, record the job ID with the result, and never increment a counter without checking whether the increment already happened.
Retry with a budget
Retries are not free. Each one spends time, money, and the patience of whatever system is downstream. A retry budget makes that cost explicit.
Use exponential backoff with jitter, cap the number of attempts, and send exhausted jobs somewhere a human will actually look. A dead letter queue nobody reads is just a slower way to lose work.
Observability that answers a question
Dashboards should answer questions, not display numbers. How long does a job wait before it starts? How often does it fail? Which deploy changed the failure rate?
Track queue delay, run time, failure rate, and retry count per job type. Alert on the delay and the failure rate, not on the existence of a single error.
Log the job, not the payload
Logs are a record of what happened, not a copy of your database. Include the job ID, type, attempt number, outcome, and duration. Leave the payload out.
When you need the payload, fetch it by job ID from the store. That keeps logs small, avoids leaking customer data, and makes retention rules easy to reason about.
Deployment
Deploying a worker is different from deploying a web server. In-flight jobs outlive the process, so the new code has to read jobs written by the old code.
Keep payloads backward compatible, drain workers before shutting them down, and roll out handler changes separately from schema changes.
Further reading
The original article on reliable background processing, the queue documentation, and the internal runbook for on-call engineers are linked from this page.