bullmq
BullMQ
BullMQ is a Redis-based distributed job and message queue for Node.js with workers, schedulers, flows, and built-in rate limiting.
Documentation
Key Capabilities
BullMQ has built-ins that replace common patterns developers reach for external solutions to solve:
- Flow Producers: model parent-child job dependencies natively — no custom orchestration layer needed. A parent job only runs after all its children complete.
- Sandboxed Processors: run worker processors in isolated child processes (
processor: './worker.js') — no separate process manager or worker-threads wiring needed. - Job Schedulers: built-in repeating job scheduler with cron and interval strategies. Note:
QueueScheduler(v1) was removed in v2 when stall detection moved intoWorker; the legacyrepeatoption onqueue.add()was separately deprecated in v5.16+ in favor ofupsertJobScheduler(). Nonode-cronneeded. - Global Rate Limiting: enforce a max-jobs-per-duration limit via the
limiteroption on theWorkerconstructor ({ limiter: { max: 10, duration: 1000 } }) — no Redis Lua scripting needed. - Built-in Metrics: track processed/failed counts and Prometheus-compatible metrics without a separate metrics library.
Best Practices
- Always close connections explicitly:
Queue,Worker, andQueueEventseach hold their own Redis connection. Call.close()on all three on shutdown or you will leak connections and block process exit. - Use
QueueEventsfor cross-process event listening: theWorkeremits events only within its own process. To listen to completed/failed events from a different process (e.g. an API server), instantiate aQueueEventsobject — not aWorker. - Job Schedulers replace Repeatable Jobs in v5.16+: the old
repeatoption onqueue.add()is deprecated. Usequeue.upsertJobScheduler()instead to avoid duplicate scheduler entries on restart. - Set
removeOnCompleteandremoveOnFail: by default completed and failed jobs accumulate in Redis indefinitely. Always configure auto-removal (e.g.{ count: 1000 }) to prevent unbounded memory growth. - Do not share a single
IORedisconnection across multiple BullMQ instances: BullMQ uses blocking Redis commands that require dedicated connections. Pass a connection config object (not a sharedIORedisinstance) so each class can create its own connection.
More from mikkelkrogsholm/dev-skills
meilisearch
Meilisearch — fast, open-source search engine with typo tolerance, faceted search, and AI-powered hybrid search. Use when building with Meilisearch or asking about its index configuration, search parameters, filters, facets, API keys, geosearch, ranking rules, or integration with JavaScript/TypeScript clients. Fetch live documentation for up-to-date details.
42shadcn-ui
shadcn/ui — copy-owned React component library built on Radix UI and Tailwind CSS. Use when building with shadcn/ui or asking about its components, CLI, theming, configuration, or integration with Next.js, Vite, Remix, or other frameworks. Fetch live documentation for up-to-date details.
10zod
Zod — TypeScript-first schema validation with static type inference. Use when building with Zod or asking about schema definitions, type inference, parsing, transformations, refinements, coercion, error handling, or integration with forms, APIs, or tRPC. Fetch live documentation for up-to-date details.
10bun
Bun — fast all-in-one JavaScript/TypeScript runtime, package manager, bundler, and test runner. Use when building with Bun, running TypeScript, managing packages with bun install, writing tests with bun test, or asking about Bun APIs, configuration, or Node.js migration. Fetch live documentation for up-to-date API details.
9better-auth
Better Auth — framework-agnostic authentication and authorization framework for TypeScript. Use when building with Better Auth or asking about its APIs, configuration, plugins, session management, OAuth, or integration. Fetch live documentation for up-to-date details.
7react
React — JavaScript library for building user interfaces with components. Use when building with React or asking about hooks, state management, effects, Server Components, Suspense, or any React APIs, patterns, or configuration. Fetch live documentation for up-to-date details.
7