
BullMQ: Production-Grade Job Queues for Node.js
BullMQ: Production-Grade Job Queues for Node.js Doing heavy work inside an HTTP request is a recipe for timeouts and poor UX. BullMQ moves work out of the request cycle into background workers — with retries, priorities, and rate limiting built in. Why a Job Queue Don't do in a request: Sending emails (slow, can fail) Image processing (CPU-bound) Calling external APIs (unreliable) Generating reports (memory-heavy) Do instead: add a job to the queue, return 200 immediately, process in a worker. Setup npm install bullmq ioredis Producer import { Queue } from ' bullmq ' ; import { Redis } from ' ioredis ' ; const connection = new Redis ( process . env . REDIS_URL ! , { maxRetriesPerRequest : null }); export const emailQueue = new Queue ( ' emails ' , { connection }); export const imageQueue = new Queue ( ' images ' , { connection }); // Add jobs from your API routes await emailQueue . add ( ' welcome ' , { to : user . email , firstName : user . firstName , }, { attempts : 3 , backoff : {
Continue reading on Dev.to
Opens in a new tab



