SysDesign study
Offline — showing the cached copy.
Home / Software System Design / 8. Queues and backpressure

8. Queues and backpressure

One-liner. A queue converts a spike into a backlog — and moves the failure to the consumer.

Memorize

  • Decouple: producer acks fast, consumer drains at its own rate.
  • Visibility timeout must exceed processing time, or you get duplicate work.
  • DLQ after N attempts; alert on depth, not just errors.
  • Backpressure: bound the queue, shed load (429), or scale consumers on queue depth.
  • Ordering only exists per partition/message group; global order costs throughput.
  • Fan-out (SNS/EventBridge → many queues) when multiple consumers each need the event.
QUEUE WITH DLQ AND AUTOSCALING Producer Queue Worker 1 Worker 2 DLQ
Queue with DLQ and autoscaling

Trap. Unbounded queues — latency grows silently until the backlog is hours deep. Do this. Define the max acceptable lag and alert on it.

Check

A consumer occasionally takes 3 minutes, but the visibility timeout is 60 s, causing duplicate processing. What is the correct fix?