~/VibeHandbook
$39

Chapter 14 · 07

Queues

A lets you say "do this later" instead of "do this now." When a user signs up, you don't want them waiting while you send a welcome email and resize their avatar. Push those jobs onto a queue (RabbitMQ, BullMQ, Cloudflare Queues, SQS); a background worker picks them up. The user gets an instant response.

Use a queue for any task that is slow, can fail and retry, or doesn't need to finish before you respond to the user.

The catch most beginners hit is that a queued job can run more than once — a network blip makes the worker retry, and now the welcome email goes out twice. The fix is to make jobs : design them so running the same job twice has the same effect as running it once (check "did I already send this?" before sending). Also decide upfront what happens to a job that keeps failing; mature queues route it to a dead-letter queue so one poison message doesn't block everything behind it.

Want it offline?

Get the PDF + EPUB + downloadable prompt library + version updates.

$ Get the PDF — $39