Retry only transient failures
Connection errors, selected 5xx responses and rate-limit responses may be temporary. Invalid parameters and ordinary 404 responses are not fixed by retrying the same request.
Use bounded exponential backoff
delay = base_delay × 2^attempt + random_jitterUse a small retry count and a maximum delay. Respect Retry-After when a 429 response provides it.
Set timeouts
Every network request should have finite connection and total timeouts. A request that waits forever can exhaust application resources even when the API itself is healthy.