Chapter 6 of 10All chapters
Chapter 6 of 10
Queues and async work
Doing it later, on purpose.
Why queue
A queue lets a request return immediately while the slow work happens behind it: emails, image processing, reports. A burst becomes a backlog instead of an outage.
- The consumer sets the pace, so it can never be overwhelmed.
- Users need feedback that the work was accepted and is pending.
Delivery guarantees
Most queues deliver at least once, so a message can arrive twice. Make consumers idempotent rather than hoping, and send failures to a dead letter queue for inspection.