Backpressure
What happens when producers outpace consumers.
Why it matters
Queues are buffers, not unlimited reservoirs. Sustained producer > consumer means backlog growth and eventual retention loss.
What backpressure means
When producers send messages faster than consumers can process and delete them, the queue backlog grows. SQS absorbs the spike temporarily, but retention limits mean unprocessed messages are eventually deleted.
Detection signals
Monitor queue depth and age. ApproximateAgeOfOldestMessage growing steadily means you're falling behind regardless of absolute message count.
- ApproximateNumberOfMessagesVisible — backlog size.
- ApproximateAgeOfOldestMessage — how stale the oldest work is.
- ApproximateNumberOfMessagesNotVisible — in-flight (being processed).
Response strategies
Address backpressure at multiple layers:
- Scale out consumers (horizontal scaling).
- Increase batch size and use long polling.
- Shed load at the producer (return 429, rate limit).
- Split traffic by priority into separate queues.
- Fix downstream bottlenecks (DB, external APIs) — more SQS consumers won't help.
DLQ and retention
DLQ traffic does not drain automatically — a filling DLQ is a separate alarm from source queue backlog. Messages in the main queue expire per retention policy if never processed.
Gotchas
- !Adding consumers may not help if the downstream DB or API is the bottleneck — measure end-to-end.
- !DLQ traffic counts toward retention but doesn't drain naturally — alarm separately.
- !Backlog growth with flat consumer count often means poison messages or visibility timeout issues, not just capacity.
Related concepts