Apply Exponential Backoff: Increase Retry Delays Safely
Exponential backoff increases the wait between retries after a transient failure according to the attempt number. It gives a service time to recover and reduces load from rapid repeated failures. Retry only errors that could recover; also cap the delay, total attempts, and overall request deadline.
Exponential backoff increases the wait between retries after a transient failure according to the attempt number. It gives a service time to recover and reduces load from rapid repeated failures. Retry only errors that could recover; also cap the delay, total attempts, and overall request deadline.
The basic calculation
Let b be the base delay, n the retry number (0 for the first retry), and cap the maximum delay:
delay = min(cap, b × 2^n)
For example, with b = 200 ms and cap = 2 s, waits are 200 ms, 400 ms, 800 ms, 1.6 s, 2 s, then 2 s. A cap prevents impractically long waits and arithmetic overflow. Compare against the cap before computing a large power, or use saturating arithmetic.
This formula sets timing; it does not decide whether to retry. Do not retry permanent failures such as malformed input or access denial. Retry timeouts or overload responses only after checking the API contract and idempotency: repeating an operation must not create duplicate effects. A missing response does not prove the server did no work.
Set the policy
**Classify errors.** Separate transient network/server errors and throttling responses from permanent errors. If the server provides a retry time such as `Retry-After`, follow the API contract and client rules.
**Choose the base and cap.** A short base can recover quickly but may keep pressure on the service. The cap should allow recovery while fitting within the user's or job's acceptable wait. Do not copy service-specific values as universal defaults.
**Bound attempts and the total deadline.** State whether “4 attempts” means the initial call plus 3 retries. Stop when the remaining overall deadline cannot fit another wait and request. Multiple layers that each retry can multiply total calls, so prefer one layer to own retries.
**Check replay safety.** Payment or create operations may need an idempotency key or deduplication before retrying.
Check actual SDK behavior
Retry behavior depends on SDK and configuration. The AWS SDK guide's updated 2026 behavior currently requires opt-in, according to its documentation. Standard mode uses different delays by error type, a cap, and a retry quota. In its example, 3 maximum attempts means 1 initial request plus 2 retries. Before adding application-level retries, check the SDK's current mode, default attempt limit, and retryable error classification to avoid duplicate retry layers.
Verification and operations
In a test environment, exercise transient errors, permanent errors, throttling responses, and deadline expiry; check intervals, maximum attempts, and final errors. Track retry count and success rate, retry delay, final failures, deadline expirations, and server errors separately. If many clients fail at once, plain exponential delays can synchronize their retries. Consider a jittered strategy when clients act concurrently. No live SDK or API request was tested here.
Sources
[Google SRE Book: Addressing Cascading Failures — Retries](https://sre.google/sre-book/addressing-cascading-failures/)
[AWS SDKs and Tools: Retry behavior](https://docs.aws.amazon.com/sdkref/latest/guide/feature-retry-behavior.html)