Try
↑ ↓ move↵ openesc close

Interview prep / Idempotency and the outbox

Junior · Idempotency and the outbox · System design interview question

What does it mean for an operation to be idempotent?

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

A strong answer

Doing it more than once has the same effect as doing it once. Setting a field to 5 is idempotent. Adding 5 to it is not.

It matters because networks lose replies. A client that did not hear back cannot tell whether the request ran, so it retries. If the operation is idempotent, the retry is harmless. If not, the retry may charge a card twice.

HTTP defines some methods as idempotent, such as PUT and DELETE. A POST is not, so APIs that create things need an extra mechanism.

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