Try
↑ ↓ move↵ openesc close

Interview prep / Delivery guarantees

Senior · Delivery guarantees · System design interview question

Your consumer sends a confirmation email through a provider that has no idempotency key. At-least-once delivery means some customers get two. What are your options?

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

A strong answer

The crash window cannot be closed completely when the provider cannot dedupe, so the real question is which error you prefer and how much you can shrink it.

Record intent before sending. Write a row for the message id with state pending, send, then set sent. On redelivery the consumer reads the state. If it is sent, skip. If it is pending, the previous attempt may or may not have gone out, and that is the gap. For an order confirmation I would send again and accept a rare duplicate. For something harmful to repeat, I would not send and would flag it for review.

Shrink the gap by keeping the pending-to-sent window short and the ack timeout longer than the provider call, so slow calls do not trigger redelivery. Use the provider's message id or delivery status, where there is one, to check whether the pending email went out.

Finally, decide the policy by cost. A duplicate confirmation is an annoyance, while a missing one may cause a support ticket. Write the choice down, and count duplicates so the rate is known.

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