Try
↑ ↓ move↵ openesc close

Interview prep / Idempotency and the outbox

Mid · Idempotency and the outbox · System design interview question

How long should you keep idempotency keys, and what goes wrong if you drop them too soon?

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

A strong answer

Keep a key at least as long as the longest period a client can retry the same operation, plus the time a request can sit in a queue. A common choice is a day.

If the key expires before a late retry arrives, the retry looks new and runs again. That is a duplicate. A key table that grows without end costs storage and index size, so expiry is needed, and the lifetime is a trade between table size and how late a retry can safely be.

Also decide what a repeat does while the first request is still running. Return a conflict, or wait for it, but do not run it twice.

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