Tensorum

Idempotency & Exactly-once

Networks retry. Your system must make the second attempt harmless.

Distributed SystemsIntermediate6 hrs4 key ideas · 5 applied designs
0%
your progress

Overview

Networks retry. Your system must make the second attempt harmless.

Key ideas

  • Exactly-once delivery is impossible; exactly-once effect is achievable with at-least-once delivery + idempotent processing.
  • Idempotency keys are stored with the result; a repeat request returns the stored result.
  • Stream processors get effectively-once by checkpointing state and output together.
  • Deduplication windows bound the storage cost of remembering keys.

Trade-offs

  • Longer dedup windows are safer but cost storage and lookups.
  • Idempotency across services needs a shared key, not just per-service guards.

In the real world

Stripe idempotency keysKafka transactionsFlink two-phase sinks

Keywords

Idempotency keysDedupEffectively-once