Some work should not happen inside a web request. Sending a welcome email, generating a PDF, resizing an image, or processing a payment webhook — if any of these run slowly, your user waits. BullMQ solves this by moving the work into a queue backed by Redis, so your API can respond instantly and the heavy work happens in the background.
The pattern is simple: a producer adds jobs, workers process them.
import { Queue, Worker } from 'bullmq';
const emailQueue = new Queue('emails', {
connection: { host: 'localhost', port: 6379 },
});
// Producer: add a job from your API route
await emailQueue.add('welcome', { userId: 42, email: 'a@example.com' });
// Worker: process jobs somewhere else
const worker = new Worker('emails', async (job) => {
await sendWelcomeEmail(job.data.email);
}, { connection: { host: 'localhost', port: 6379 } });
BullMQ adds the features that make queues production-ready: automatic retries with backoff when a job fails, delayed jobs that run later, rate limiting, job priorities, and a dashboard to see what is stuck. If your email service is down, the job retries instead of disappearing.
One thing to know: BullMQ needs Redis. For a small side project that might be overkill — a simple in-process queue or a cron job may be enough. But once you have real users and real background work, a proper queue is the difference between an app that survives a traffic spike and one that falls over.
BullMQ is for Node.js developers whose apps do slow work — emails, file processing, notifications, webhooks — and want it done reliably in the background instead of inside the request.
Top comments (0)