Scale workers
Throughput is the number of tasks your workers run at once, divided by how long a task takes. There are three ways to raise the first number, and three controls on the server that cap it on purpose.
A task's life
Every task a worker holds is a lease of 30 seconds that the worker keeps renewing. A worker that dies stops renewing, and its tasks go back to waiting. For a job, Failed is the dead letter queue; for a workflow step, the engine decides.
Raise it
| Step | What changes | When |
|---|---|---|
1. Raise concurrency | Tasks one worker process runs at once | The process has CPU and memory to spare, and tasks mostly wait on I/O |
| 2. Run more worker processes | Processes polling the same queues | One process is out of CPU, or you want it to survive a crash |
| 3. Run more server instances | Capacity of the SDK gateway | The server is out of CPU and Redis is not: see Scale the server |
Take them in that order. Any number of workers may serve the same queue; the server hands each task to one of them.
| Setting | Default | What it does |
|---|---|---|
concurrency | 4 | Tasks the process runs at once |
prefetch | half of concurrency, at least 1 | Extra tasks it holds ready, so a free slot never waits for a poll |
lease_ttl_ms | 30,000 | How long a task stays claimed without a renewal. The worker renews every third of it |
drain_timeout | 30 seconds | How long a stopping worker may finish what it holds |
- A worker holds up to
concurrency + prefetchtasks. On a queue that must be shared fairly between few workers, keepprefetchlow: prefetched tasks wait in one worker while another may be idle. - Each language uses what it has: threads in Python, Ruby, Rust and Java, goroutines in Go, tasks in .NET, processes in Elixir, async loops in TypeScript. PHP forks
concurrencyprocesses with ext-pcntl, and runs one task at a time without it. - A worker blocked for longer than the lease loses its tasks (
LeaseExpired). For CPU-heavy handlers in a language with one interpreter thread, prefer more processes with a lowerconcurrency.
Queue workers and workflow workers scale differently
| Queue worker | Workflow worker | |
|---|---|---|
| Add workers when | joobqui_queue_size of its queues grows | Runs stay at a step for longer than the step takes, or steps time out waiting for a worker (schedule_to_start_ms) |
| One unit of work | A whole job | One step. A run of ten steps is ten tasks, possibly on ten different workers |
| What limits a single run | The job's handler | The slowest step, and how long each step waits for a free slot |
prefetch | Helps short jobs | Keep it low for long steps: a prefetched step waits in one worker while another may be idle |
Steps of one run that are declared parallel run at the same time only if enough slots are free on the task queue, so size a workflow worker for the widest parallel group you expect, times the runs in flight.
A worker that does both shares one concurrency between jobs and steps. Split them into two deployments when one kind starves the other: see Queue workers and workflow workers.
Cap it
These are set on the server and apply to every worker, whatever its language: see Queue throttling and controls.
| Control | Effect | Where |
|---|---|---|
| Pause | Workers stop taking the queue's jobs until it is resumed | Queues page |
| Concurrency | At most that many of the queue's tasks run at once, across all workers | Queues page |
| Throttle | At most limit jobs per period, across all workers; a throttled queue hands out one task per poll | Queues page |


A throttled or paused queue looks like slow workers. Check the Queues page before adding more.
What to expect
Measured with handlers that do nothing, on one shared 4-core machine, one worker process ran 1,900 to 2,700 jobs per second. Real handlers set the rate long before the worker or the gateway does. See Benchmarks for the tables and Capacity.
Check it worked
- The Workers page shows every process, and how many of its slots are busy.
joobqui_queue_size{queue}falls, andjoobqui_jobs_processed_total{queue}rises faster than before.joobqui_queue_dead{queue}does not rise: more load often finds the errors a quiet system hid.