BullMQ
Overview
BullMQ is a fast, Redis-backed distributed queue for Node.js (with Python, Rust, and other ports) used to offload work to background workers: emails, image processing, webhooks, scheduled jobs. It provides retries, delays, priorities, rate limiting, and parent-child job dependencies with atomic, Lua-backed operations. Read this when a Node service needs reliable background processing instead of doing work inside the request cycle.
Official sources
Install / setup
npm install bullmq
Requires a running Redis instance (the examples assume a local Redis on localhost:6379).
Core concepts
- Queue: a named queue you add jobs to (
new Queue('foo')); producers enqueue, consumers process independently.
- Worker: a process that pulls jobs from a queue and runs a processor function; multiple workers scale horizontally across the same queue.
- Job: a unit of work with data and options (attempts, backoff, delay, priority); BullMQ tracks its lifecycle (waiting, active, completed, failed).
- Connection: BullMQ talks to Redis via ioredis; workers require
maxRetriesPerRequest: null on the connection.
- Flows (parent-child): jobs can depend on child jobs and only run after children complete, enabling fan-out/fan-in pipelines.
- QueueEvents: a separate listener stream for observing job state changes (completed, failed, progress) across processes.
Best practices
- Make job processors idempotent — BullMQ targets reliable delivery, and retries/replays mean the same job may run more than once.
- Configure
attempts and backoff per job so transient failures retry with exponential delay instead of failing permanently.
- Reuse a single Redis connection (ioredis instance) across queues/workers where appropriate rather than opening one per object.
- Run dedicated worker processes separate from your web/API process so heavy jobs do not compete with request handling.
Common pitfalls
- Creating the Worker connection without
maxRetriesPerRequest: null → BullMQ requires this and will warn/error otherwise.
- Doing long blocking work in a processor without concurrency or rate limits → set worker
concurrency and rate limiting to control throughput against downstream systems.
- Assuming jobs run in the web process → without a separate Worker actually consuming the queue, jobs sit in "waiting" forever.
Examples
import { Queue, Worker } from 'bullmq';
import IORedis from 'ioredis';
const connection = new IORedis({ maxRetriesPerRequest: null });
const myQueue = new Queue('foo', { connection });
await myQueue.add('myJobName', { foo: 'bar' }, { attempts: 3, backoff: 5000 });
new Worker('foo', async job => {
console.log(job.data);
}, { connection });
Further reading
Related skills
- ../redis — the data store BullMQ runs on; understand TTLs and persistence
- ../celery — equivalent task-queue pattern for Python services
1---2name: bullmq3description: Redis-backed distributed job queue for Node.js; consult when adding background jobs, retries, delays, or scheduled work to a Node service.4domain: stack5category: queue6tags: [bullmq, queue, jobs, nodejs, redis, background-jobs]7official_sources:8 - https://docs.bullmq.io/9 - https://github.com/taskforcesh/bullmq10verified: 2026-06-1611metadata:12 source: https://skillmd.com/skills/gabriel7silva/bullmq13---1415# BullMQ1617## Overview18BullMQ is a fast, Redis-backed distributed queue for Node.js (with Python, Rust, and other ports) used to offload work to background workers: emails, image processing, webhooks, scheduled jobs. It provides retries, delays, priorities, rate limiting, and parent-child job dependencies with atomic, Lua-backed operations. Read this when a Node service needs reliable background processing instead of doing work inside the request cycle.1920## Official sources21- Docs: https://docs.bullmq.io/22- Repo: https://github.com/taskforcesh/bullmq23- Install / quick start: https://docs.bullmq.io/readme-12425## Install / setup26```bash27npm install bullmq28```29Requires a running Redis instance (the examples assume a local Redis on `localhost:6379`).3031## Core concepts32- **Queue**: a named queue you add jobs to (`new Queue('foo')`); producers enqueue, consumers process independently.33- **Worker**: a process that pulls jobs from a queue and runs a processor function; multiple workers scale horizontally across the same queue.34- **Job**: a unit of work with data and options (attempts, backoff, delay, priority); BullMQ tracks its lifecycle (waiting, active, completed, failed).35- **Connection**: BullMQ talks to Redis via ioredis; workers require `maxRetriesPerRequest: null` on the connection.36- **Flows (parent-child)**: jobs can depend on child jobs and only run after children complete, enabling fan-out/fan-in pipelines.37- **QueueEvents**: a separate listener stream for observing job state changes (completed, failed, progress) across processes.3839## Best practices40- Make job processors idempotent — BullMQ targets reliable delivery, and retries/replays mean the same job may run more than once.41- Configure `attempts` and `backoff` per job so transient failures retry with exponential delay instead of failing permanently.42- Reuse a single Redis connection (ioredis instance) across queues/workers where appropriate rather than opening one per object.43- Run dedicated worker processes separate from your web/API process so heavy jobs do not compete with request handling.4445## Common pitfalls46- Creating the Worker connection without `maxRetriesPerRequest: null` → BullMQ requires this and will warn/error otherwise.47- Doing long blocking work in a processor without concurrency or rate limits → set worker `concurrency` and rate limiting to control throughput against downstream systems.48- Assuming jobs run in the web process → without a separate Worker actually consuming the queue, jobs sit in "waiting" forever.4950## Examples51```typescript52import { Queue, Worker } from 'bullmq';53import IORedis from 'ioredis';5455const connection = new IORedis({ maxRetriesPerRequest: null });5657const myQueue = new Queue('foo', { connection });58await myQueue.add('myJobName', { foo: 'bar' }, { attempts: 3, backoff: 5000 });5960new Worker('foo', async job => {61 console.log(job.data);62}, { connection });63```6465## Further reading66- https://docs.bullmq.io/guide/workers — workers, concurrency, rate limiting67- https://docs.bullmq.io/guide/flows — parent-child job flows6869## Related skills70- ../redis — the data store BullMQ runs on; understand TTLs and persistence71- ../celery — equivalent task-queue pattern for Python services