Retries Make Cloud Incidents Worse Without an Idempotency Contract
The hardest moment in a cloud API call is not always an error response. It is the moment when the client cannot tell whether the request reached the server, whether the server started the operation, or whether only the response disappeared from the network. The client sees a timeout and sends the same request again. If the first request already created an instance or a network port, the retry creates a duplicate instead of recovering the operation.

This is not merely a bug in one SDK. In a distributed system, “the response was not received” does not mean “the operation was not executed.” A network interruption, an API gateway restart, message-queue delay, or service-process failure can all produce the same ambiguous result. A safe cloud API is not one that never fails. It is one whose result converges to a single outcome when the client retries after an ambiguous result.
Separate retryable work from unsafe repetition
A read-only request such as GET can usually be sent more than once without changing state. Even a read can return different results depending on timing or authorization, so the client still needs to validate the current state. Creation requests made with POST need more care. Whether sending the same body twice creates two resources or returns the first result is part of the API contract.
Operators should not define retry policy from the HTTP method alone. An action such as “reboot the server” or “attach the volume” can be dangerous when repeated, while an action such as “make the resource active” may be safe if only the final state matters. Each operation should specify three things:
- What identifier determines that two requests are the same?
- What result does the server return when the same request arrives again?
- What lookup does the operator perform when the first result cannot be observed?
Idempotency does not mean “retry whenever a request fails.” It means that processing several requests representing the same intent produces the same observable final state as processing the intent once.
A request ID is not an idempotency key
In an OpenStack environment, a request ID is valuable for tracing. It connects logs across services such as Nova, Neutron, and Keystone and helps operators find the path of one call. But if a request ID is issued again for a retry or changes at a proxy boundary, the server cannot use it to identify the two requests as one intent. A tracing identifier and a deduplication key have different jobs.
An idempotency key should be assigned by the client to a logical operation. For example, the operation “project A creates one server for order 2026-1130-0042” gets a key that remains the same through network retries and worker restarts. The server should store the key together with the tenant and operation type. Comparing keys globally can make legitimate requests from different projects collide.
The stored record also needs a fingerprint of the request body. If the same key later asks for a different image or network, the server must not quietly return the first result. It should return a clear error such as idempotency key reused with different parameters. Otherwise, an old automation configuration can look like a new request and become difficult to investigate.
Implement idempotency as a state machine
Recording a key in a database is not enough. If two requests can check the key and create the resource in separate steps, concurrent retries can both conclude that the operation has not started. Acquiring ownership of the operation and storing the key must be atomic, or protected by a database uniqueness constraint and appropriate locking.
The server should distinguish at least these states:
- accepted: The request was accepted and an owner for the work was selected.
- processing: Resource creation or the state transition is in progress.
- succeeded: The final resource identifier and result were stored.
- failed: The failure reason and whether another attempt is allowed were determined.
When the same key arrives in processing, the server should not start a second job. It should return the current state or an appropriate retry instruction. In succeeded, it should return the same resource identifier as the first response. failed is more nuanced: a network problem may allow another attempt, while an invalid image or missing permission requires a corrected request.
The essential property is that the server can describe the result later. If an asynchronous response disappears, the client must be able to query by the idempotency key or operation ID and learn whether the resource already exists, is still being created, or failed. Without that lookup, clients either retry blindly and create duplicates or give up on recovery.
Treat the service boundaries as one contract
A cloud API rarely ends inside one service. Creating a Nova server can involve an image, networks, ports, and block storage. A Neutron port can then require binding and security-group application. A key attached to the external Nova request does not automatically give the lower-level services the same idempotency behavior.
The platform team should record the relationship between the user request and its internal work. A parent operation key, child-resource owner, creation order, and compensating action make partial success discoverable. If server creation fails but a port remains, the next attempt should check whether the existing port belongs to the original operation before creating another one. System-managed correlation metadata is safer than guessing from a name or tag.
Trying to roll back every child operation can also create a larger risk. A volume or port may already have been exposed to a user, or another system may have recorded its identifier. Recovery design should first decide which state can be reused and which state must be isolated, rather than assuming that everything should be deleted.
Look up before retrying after a timeout
The common client policy is exponential backoff followed by another request. That can work for reads, but creation and state-changing operations should reverse the order. First look up the operation with the same idempotency key. Only when there is evidence that the server does not know the key should the client decide whether to retry. There is still a race between lookup and retry, so the server must suppress duplicates when the second request arrives.
A retry policy should distinguish these boundaries:
- Connection failures and 502, 503, or 504 responses whose outcome is ambiguous
- Authentication, authorization, and input errors that will not change when repeated
- Queue congestion or rate limits that require waiting
- Asynchronous work that was accepted and now requires a result lookup
Applying the same retry count to every error sends more traffic to a failing control plane. In an automated system with several workers, those retries can combine into queue overload. Exponential backoff, a maximum attempt window, a retry budget, and a circuit breaker should be operated alongside the idempotency contract.
Make idempotency observable
Searching logs for the cause after duplicate creation is too late. Record the request key, request fingerprint, tenant, parent operation ID, current state, first acceptance time, and most recent retry as structured fields. The rate of creation requests without an idempotency key is also worth measuring. It shows whether a new client is bypassing the platform’s safety boundary.
Useful alerts include:
- The number of times one key arrives with different request fingerprints
- Retry count and processing time for the same key
- Operations that remain in
processingbeyond their expected window - Multiple equivalent resources created under one parent operation
- Requests whose result can no longer be recovered because the key expired
Retention should be based on the client’s maximum retry window, message-queue delay, and post-outage replay window. Deleting a key too early allows a late retry to become a new operation. Keeping every key forever grows storage and may retain sensitive request data unnecessarily, so a safer design can retain a fingerprint and result rather than the full request body.
Lock the contract in tests
Idempotency cannot be proven by happy-path unit tests. Reproduce the case where the server succeeds and only the response is lost, where the process restarts immediately after recording the key, where the same key arrives concurrently, and where only a lower-level service succeeds. The success condition is not simply receiving a 200 response. It is that exactly one equivalent resource exists and can be looked up afterward.
Before production, the team should be able to answer these questions:
- Are idempotency keys required or generated by default for creation and state changes?
- Are keys isolated by tenant and operation type?
- Are different request bodies under the same key detected?
- Is there an API and an operator tool for lookup after a timeout?
- Can partially created child resources be identified, reused, isolated, or cleaned up?
- How long are keys and results retained, and how are late retries rejected after expiry?
Cloud reliability does not come from every request succeeding on its first attempt. It comes from accepting that networks and processes can fail in the middle, then making repeated deliveries of the same intent converge to one state. An idempotency key looks like a small header, but behind it are ownership, a state machine, service relationships, retry budgets, and recovery responsibility. A platform that fixes this contract in documentation, tests, and observability can turn timeouts into safe retries instead of duplicate incidents.