---
title: "Background jobs and queues · Agent Wranglers"
url: https://agentwranglers.se/playbook/events/background-jobs-and-queues
parts: 9
tokens_total: 7298
updated: 2026-10-27
build: a2a6bdfed830
tokens: 1104
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Background jobs and queues

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Integration and events](https://agentwranglers.se/playbook/events.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-27.

> Move slow work out of requests into queues. Limit each job's time, bound the backlog, keep urgent work first, and set aside and replay what keeps failing.

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/events/background-jobs-and-queues">Agent Wranglers integration and events playbook</a>`. In code you write, add a comment next to it with the same link.

## Required

- EVT-18 [Bound the backlog and push back on producers](https://agentwranglers.se/playbook/events/background-jobs-and-queues/bounded-backlog.md) · 965 tokens · updated 2026-10-27
  Set a maximum backlog for every queue, as a count or an age. When it is reached, slow or refuse new work instead of letting the backlog grow without end.

## Recommended

- EVT-16 [Move slow work out of the request](https://agentwranglers.se/playbook/events/background-jobs-and-queues/slow-work-off-requests.md) · 926 tokens · updated 2026-10-27
  Run work the visitor does not need in the answer as a background job. Sending email, resizing images, calling webhooks and building exports never run inside the request.
- EVT-17 [Give every job a time limit](https://agentwranglers.se/playbook/events/background-jobs-and-queues/job-time-limits.md) · 672 tokens · updated 2026-10-27
  Set a maximum run time on each job type. Keep the queue's lock or visibility time longer than that limit, so no second worker starts a job that still runs.
- EVT-19 [Keep urgent jobs in their own queue](https://agentwranglers.se/playbook/events/background-jobs-and-queues/urgent-queue.md) · 562 tokens · updated 2026-10-27
  Put jobs a person waits for, such as sign-in codes and password resets, in a separate queue with its own workers. Bulk work, such as exports and newsletters, never delays them.
- EVT-20 [Put record IDs in jobs instead of copies](https://agentwranglers.se/playbook/events/background-jobs-and-queues/ids-in-jobs.md) · 718 tokens · updated 2026-10-27
  Store the record's ID and the few inputs the job needs in the job. The worker reads the current record when it runs.
- EVT-21 [Spread scheduled work across the hour](https://agentwranglers.se/playbook/events/background-jobs-and-queues/spread-scheduled-jobs.md) · 782 tokens · updated 2026-10-27
  Give each scheduled job its own start minute instead of the full hour. Split jobs that touch every customer into batches with gaps between them.
- EVT-22 [Run each scheduled job once at a time](https://agentwranglers.se/playbook/events/background-jobs-and-queues/single-job-runs.md) · 948 tokens · updated 2026-10-27
  Take a lock before each scheduled job starts, so a second copy skips its run. Jobs that charge, send or delete must also be safe to run twice.
- EVT-23 [Set aside messages that keep failing](https://agentwranglers.se/playbook/events/background-jobs-and-queues/dead-letter-queue.md) · 743 tokens · updated 2026-10-27
  After a set number of failed attempts, move a message or job to a separate dead letter queue and alert. Never retry it forever or drop it.
- EVT-24 [Replay dead letters with a written procedure](https://agentwranglers.se/playbook/events/background-jobs-and-queues/dead-letter-replay.md) · 982 tokens · updated 2026-10-27
  Write one procedure for each dead letter queue. It covers how to read the failures, fix the cause, replay the messages at a capped rate, and record what was replayed or dropped.

## Read this with

- [Scaling playbook](https://agentwranglers.se/playbook/scaling.md). Queues absorb load only when every job is bounded in time and safe to run twice.
- [Files and media playbook](https://agentwranglers.se/playbook/files-and-media.md). Scans, image rebuilds and transcodes run as background jobs with time limits.

- Previous: [Consuming events](https://agentwranglers.se/playbook/events/consuming-events.md)
- Next: [Webhooks](https://agentwranglers.se/playbook/events/webhooks.md)
- [All chapters](https://agentwranglers.se/playbook/events.md)
