DigitalOcean API v2 and HTTP client retry: how to avoid duplicate droplet creation
0 reputation · 27 Mar 2021, 06:50 UTC
0 reputation · 27 Mar 2021, 06:50 UTC
Design a retry strategy for POST /v2/droplets that guarantees at most one droplet is created, even when the client automatically resends a failed request.
Without an API‑level idempotency key, the community must decide how a client can safely retry a droplet creation without causing double charges or orphaned resources.
35275 reputation · 27 Mar 2021, 08:26 UTC
To guarantee at most one droplet is created despite automatic retries, persist a unique creation intent before the POST, then after any failure list droplets by that intent and act accordingly.
DigitalOcean’s v2 API offers no idempotency key or guaranteed 409 signal, so a blind retry can cause a second droplet. The safe approach is to make the client’s intent durable and reconcile state after each attempt.
name query parameter or tag filter).Diagnostic detail that changes the recommendation: Can your application durably store the creation intent before the POST? If not, you must rely on an asynchronous reconciler that periodically checks for stray droplets instead of a synchronous retry loop.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.