Try
↑ ↓ move↵ openesc close

Interview prep / Idempotency and the outbox

Junior · Idempotency and the outbox · System design interview question

How does an idempotency key stop a duplicate request?

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

A strong answer

The client generates a unique key for one logical operation and sends it with every attempt, including retries. The server stores the key with the result of the first run. If a request comes with a key it has seen, it returns the stored result and does nothing else.

The key must identify the operation, not the attempt. A new random key on each retry defeats it. Store the key and the effect in one transaction, so a crash cannot leave one without the other.

Sources

Learn it by running it

The idempotency keys and the outbox 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