Job Queue
ELI5 — The Vibe Check
A job queue is a to-do list for your server. When work comes in that doesn't need to happen immediately — sending emails, resizing images, generating reports — you put it on the queue and workers pick it up when they're free. It's like a ticket counter: take a number, we'll get to you.
Real Talk
A job queue is a data structure that holds tasks to be processed asynchronously by worker processes. Jobs are enqueued by producers and dequeued by consumers/workers. Queues provide decoupling, load leveling, retry logic, and priority handling. Common implementations include BullMQ (Redis), Celery (Python), and Sidekiq (Ruby).
Show Me The Code
import { Queue, Worker } from 'bullmq';
const emailQueue = new Queue('emails');
await emailQueue.add('welcome', { userId: 123 });
new Worker('emails', async (job) => {
await sendEmail(job.data.userId);
});
When You'll Hear This
"Push the PDF generation to the job queue so the API responds immediately." / "The email job queue processes 50,000 messages per hour."
Related Terms
Background Job
A background job is work your app does behind the scenes that the user doesn't wait for.
Message Queue
A Message Queue is a waiting room for tasks. Producers drop tasks in the queue, consumers pick them up and process them one at a time.
Redis
Redis is an incredibly fast database that lives entirely in memory (RAM). It's used as a cache, a session store, and a message queue.
Worker
A worker is a background process that picks up jobs from a queue and does the heavy lifting.