Development & AI Upgrades · Practical News

Should a Timed-Out API Call Be Retried

Source: Paddy Dance teamKeywords: should timed out requests be retried

How to make an endpoint idempotent

The client generates a unique request key and sends it along. The server checks whether that key was already processed and returns the stored result instead of executing again.

A unique index in the database is the backstop. Checking then inserting does not survive concurrency on its own.

Retry policy

Keep attempts to two or three, with exponential backoff and jitter so all clients do not retry in the same instant.

Total retry time must stay under the upstream timeout. Otherwise the caller has already given up while retries keep running.

Choosing timeouts

Too long and failing requests occupy all workers, causing cascading failure; too short and slow-but-healthy requests are killed. Base it on the real latency distribution, typically P99 plus headroom.

Set timeouts per endpoint: queries short, exports and batch jobs long. A single global value is always wrong somewhere.

FAQ

Are POST requests never retryable?

They are retryable with an idempotency key, provided the server can detect duplicates.

Do retries amplify outages?

Yes. Unlimited retries against an overloaded service make it worse. Limit attempts, back off, and consider circuit breaking.

If I do not retry, users click again. What then?

Disable the button and debounce on the client, but keep the idempotency key on the server. Both layers are needed.

Related questions

designing idempotent endpointsretry caused duplicate ordersexponential backoff strategyhow to set timeouts

Further reading

Sources & References

The following are public sources. Always check the latest requirements on the official authority or platform page.

Explain your case first, then confirm the scope

Tell us your entity, business model and current progress. We will confirm what we can assist with and what you need to do before discussing fees.