Timeouts, Retries, and Backoff: Stop Making Outages Worse
Design client retry behavior that recovers from transient failures without amplifying an incident.
When an API slows down, clients often respond in the worst possible way: they retry immediately, in lockstep, with no upper bound. That turns a small slowdown into a traffic surge. This article describes how to set timeouts and retries so clients help rather than hurt.
Why timeouts come first
A retry policy without a timeout is not a policy. If a request can hang forever, no retry logic will run. Set two timeouts:
- Connection timeout: how long to wait for a TCP or TLS connection. This is usually short.
- Request timeout: the full deadline for the response, including body download.
Choose the request timeout from the user's patience and the endpoint's normal behavior. A 30-second timeout on an interactive endpoint that normally answers in 200 ms will leave users staring at a spinner during an incident. A two-second timeout on a report export will produce false failures. Different endpoints need different deadlines.
Which failures are worth retrying
Retry when the failure is likely to be transient and the request is safe to repeat. Connection resets, timeouts, and some 5xx responses are reasonable candidates. A 400, 401, 403, or 404 will not fix itself with another attempt. A 429 explicitly asks you to slow down.
Idempotency matters. Repeating a GET is harmless. Repeating a payment POST can charge twice unless the server supports an idempotency key. If the operation is not idempotent, either do not retry automatically or require a key that lets the server recognize the repeat.
Backoff and jitter
Backoff means waiting longer between each attempt. A simple pattern is 100 ms, 200 ms, 400 ms, and so on, with a capped maximum. Jitter means adding randomness to the wait. Without jitter, thousands of clients that failed at the same moment retry at the same moment, creating a thundering herd.
A practical client policy looks like this:
- Allow at most three attempts for an idempotent request.
- Use exponential delays with full jitter:
sleep(random(0, base * 2^attempt)). - Cap the base delay and total elapsed time.
- Honour
Retry-Afterwhen the server provides it. - Never retry a non-idempotent write without an idempotency key.
Circuit breakers
If one dependency is failing consistently, continuing to send requests wastes resources on both sides. A circuit breaker tracks recent failures and temporarily stops calls, returning a fast fallback or error. After a cool-down period it allows a small number of probe requests to see whether the dependency recovered.
The breaker should be scoped to the dependency, not to the whole application. A failing recommendation service should not prevent users from reading their own orders.
Observe the client side too
Server dashboards often show a modest error rate while clients are retrying heavily. Track retry counts, retry reasons, and the final outcome after retries. A rising retry rate is an early signal that a dependency is degrading.
Use the API checker to measure the real response time of a failing endpoint from outside your infrastructure. If a request takes longer than your client timeout, that mismatch explains many user-visible failures.
A checklist
- Set connection and full-request timeouts per endpoint.
- Retry only transient failures on idempotent calls.
- Add jitter to exponential backoff.
- Respect Retry-After.
- Use idempotency keys for writes.
- Add circuit breakers around fragile dependencies.
- Measure retries as a first-class metric.
Good retry behavior is mostly restraint. The goal is to survive a brief failure without amplifying it.
Related Tools
What is API Response Time? The Complete Guide to Measuring & Optimizing API Performance
Learn everything about API response time, why it matters for your business, and how to optimize your API performance wit...
How to Reduce API Latency: 10 Proven Strategies for 2026
Discover 10 proven strategies to reduce API latency and improve your application's performance. From caching to edge com...
API Monitoring Best Practices: The Complete Guide for 2026
Learn API monitoring best practices to ensure your services are reliable, fast, and always available. Covers uptime moni...
Understanding TTFB: Time to First Byte Explained — The Key to API Performance
A deep dive into TTFB (Time to First Byte), what it means for your API performance, and how to improve it with actionabl...
API Speed Test: How to Benchmark Your REST & GraphQL APIs in 2026
Complete guide to API speed testing. Learn how to benchmark REST and GraphQL API performance, interpret results, and opt...
How to Achieve 99.99% API Uptime: The Definitive Guide
Learn how to achieve 99.99% API uptime with proven strategies including redundancy, failover, monitoring, and incident r...