Place a queue between the part of a system that receives work and the part that does it, so that spikes in demand are absorbed by the queue rather than overwhelming the consumer.

The problem

Demand is rarely smooth. A marketing email goes out, a batch job finishes, or it’s 9am on a Monday, and requests arrive many times faster than usual. If the service doing the work (or something it depends on, such as a database or a third-party API) can’t scale as fast as the spike, requests time out, errors cascade and users get a bad experience.

The solution

The producer writes a message to a durable queue and moves on. One or more consumers read from the queue at a rate they can sustain. The queue absorbs the peaks; the consumers work through the backlog.

In the cloud this is usually a managed queue (Amazon SQS, Azure Service Bus or Storage Queues, Google Cloud Pub/Sub) with consumers that are serverless functions or containers scaled on queue depth.

A queue absorbs bursts between producers and consumersProducersDurable queueConsumerssteady rateDatabaseor APIDead-letter queueafter N failed attempts
Bursty producers write to a durable queue; consumers work through it at a steady rate, protecting what's behind them.

When to use it

Trade-offs