.NET Architecture & System Design Interview Question #97
What is an idempotency key?
Transactions, CQRS, Event Sourcing & Distributed Consistency Mid-Level Intermediate
Quick Interview Answer
An idempotency key is a client-supplied or workflow-generated identifier representing one logical operation. The server stores the key with the operation's result or processing state.
Detailed Explanation
An idempotency key is a client-supplied or workflow-generated identifier representing one logical operation. The server stores the key with the operation's result or processing state.
When the same key is received again, the server can return the existing result or continue the same operation instead of creating a duplicate effect. Keys need an appropriate uniqueness scope, retention period, and concurrency-safe implementation.
Code Example
Key: order-42-payment-v1
Store:
Key -> Status -> Result
Duplicate request with same key
-> reuse recorded outcome