A dependency was down for ten minutes, and 200,000 healthy messages ended up in the dead-letter queue. How do you recover, and how do you stop it happening again?
Sketch your own answer first, then compare it with the one below.
A strong answer
Recovery first. The messages are valid, so redrive them. Do it at a controlled rate, not all at once. Pushing 200,000 back immediately lands a spike on top of normal traffic and may knock the dependency over again. At 500 a second the redrive takes 400 seconds. Watch queue age and the dependency's error rate while it runs, and pause if either rises. The consumer must be idempotent, since some of these messages may have partly run before.
Prevention has two parts. The retry limit and spacing should outlast a plausible outage. Three tries 30 seconds apart gives up after about 90 seconds, so a ten minute outage dead-letters everything. Better, stop consuming while the dependency is known to be down: a circuit breaker around the call, which pauses the consumer or returns messages to the queue with a delay, so attempts are not spent.
Distinguish permanent errors, which go to the DLQ at once, from transient ones, which should not burn attempts so quickly. Alarm on DLQ arrival rate, so a flood pages someone within a minute and not after the weekend.
Sources
- Betsy Beyer, Chris Jones, Jennifer Petoff, Niall Richard Murphy (eds.) (2016). Addressing Cascading Failures.
- Amazon Web Services documentation (2024). Using dead-letter queues in Amazon SQS.