Try
↑ ↓ move↵ openesc close

Interview prep / Delivery guarantees

Senior · Delivery guarantees · System design interview question

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

Learn it by running it

The delivery guarantees lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms