Skip to content
Get started
Get started
Worker Concurrency and Batch Pulling
guide · worker

More at once, fewer round-trips.

Concurrency decides how many jobs a single worker runs in parallel. Batch pulling decides how many it fetches per request. Together they set the ceiling on what one process can do.

const worker = new Worker('my-queue', processor, {
embedded: true,
concurrency: 5, // Up to 5 jobs at once (default: 1)
});

You can change concurrency at runtime, without restarting:

worker.concurrency = 10; // Scale up under load
worker.concurrency = 2; // Scale back down (minimum: 1)

Runtime concurrency changes are a Bun client feature; the external SDKs fix concurrency at construction.

For high-volume queues, pull many jobs per round-trip and long-poll while idle:

const worker = new Worker('queue', processor, {
embedded: true,
batchSize: 100, // Request up to 100; free concurrency slots cap the pull
pollTimeout: 5000, // Wait up to 5s for jobs (long polling)
});

Bulk pushes wake idle long-polling workers immediately, they never wait out the timeout.

WorkerCreate a worker and process your first job
The Job Object Inside a Worker ProcessorEverything the processor receives and can do
Worker Eventscompleted, failed, stalled and the rest
Worker Error Handling, Retries and BackoffRetries, backoff, timeouts and giving up
Worker LifecyclePause, resume and shut down without losing work
Heartbeats, Stall Detection and Lock OwnershipHeartbeats, stall recovery and lock ownership
SandboxedWorkerExperimental isolation for CPU-heavy handlers
WorkerOptions ReferenceEvery WorkerOptions field, with defaults