# Exponential backoff

> Exponential backoff is the retry strategy of waiting longer after each failed attempt (1 s, 2 s, 4 s, 8 s…), used for 429 and 5xx responses so that retries do not amplify an overload.

When a request fails for a transient reason, such as a timeout, a 503 or a [429](https://smsmeteor.io/glossary/rate-limit), retrying at once and repeatedly makes the overload worse, for you and for everyone sharing the service. Exponential backoff spaces the attempts out: wait a base delay, double it after each failure up to a ceiling, and stop after a fixed number of attempts or a deadline.

Two refinements matter in practice. Jitter, a random component in each delay, stops many clients that failed at the same moment from retrying in lockstep and knocking the service over again. And the server's own guidance wins: when a 429 carries `Retry-After`, that value takes precedence over the computed delay. Backoff also only makes sense alongside idempotency, since a retried send must never become a duplicate.

Response | Retry?
429 | Yes, after `Retry-After`
5xx, timeout, network error | Yes, with backoff and the same idempotency key
Most other 4xx | No; fix the request

## Example

A hypothetical client starts at one second, doubles the delay each time and adds full jitter, making five attempts in all: between them it waits a random time of up to 1, 2, 4 and then 8 seconds. A brief outage costs a few seconds and no duplicates; a long one ends with the message parked in a queue and an alert raised, instead of an endless loop.

## Common mistakes

- Backoff without jitter, so that every client retries at the same instants.

- Retrying validation errors that will fail identically every time.

- Generating a new idempotency key for each attempt.

- Stacking retries in several layers, library, application and queue, which multiplies the attempts.

At SMSMeteor: the retry policy recommended on the [SDKs page](https://smsmeteor.io/docs/sdks) is to retry 429 after `Retry-After` seconds, and 5xx with exponential backoff starting at one second, five attempts. Always reuse the same [idempotency key](https://smsmeteor.io/glossary/idempotency-key) on a retry, never a new one for the same logical message; do not retry 4xx other than 429, but fix the request instead. Webhook deliveries to your endpoint apply the same principle in the other direction: six attempts over 24 hours (immediately, then +1 min, +5 min, +30 min, +2 h and +12 h), after which the event is marked undelivered and can be replayed from the panel for 30 days. See the [webhooks documentation](https://smsmeteor.io/docs/webhooks).

Related terms: [Idempotency key](https://smsmeteor.io/glossary/idempotency-key), [Rate limit](https://smsmeteor.io/glossary/rate-limit), [Webhook](https://smsmeteor.io/glossary/webhook)

---
Source: https://smsmeteor.io/glossary/exponential-backoff (HTML). Generated by SMSMeteor from the same data as the page. Summary of the whole site: https://smsmeteor.io/llms.txt
