Try
↑ ↓ move↵ openesc close

Interview prep / Delivery guarantees

Junior · Delivery guarantees · System design interview question

A message has failed processing five times in a row. What should happen to it, and why not retry forever?

Sketch your own answer first, then compare it with the one below.

A strong answer

It should move to a dead-letter queue after a set number of attempts. Most brokers can do this by a configured limit: in SQS it is the max receive count on the redrive policy.

Retrying forever has two costs. First, the message occupies consumer time on every attempt. A message that fails in 50 ms and is redelivered at once burns 20 attempts a second. Second, in an ordered queue it can block the messages behind it.

The dead-letter queue keeps the message for a person or a repair job. It only helps if somebody looks, so alarm on anything arriving there, keep the original body with the last error, and give it a longer retention than the source queue.

Also separate failures by kind. A validation error will never succeed, so it can be dead-lettered at once. A timeout from a dependency might heal, so it gets more attempts spaced further apart.

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