Go to content
Web development

Designing Retry Budgets for Microservices

You run microservices that call each other over a network, and those calls fail. A connection drops, a downstream service slows down, a pod restarts. Retrying the request fixes a real class of problems: transient failures that clear up in milliseconds. But every retry is a new request that consumes the same CPU, memory, threads, and connections as the original, so retries also cause some of the worst outages in distributed systems. When a service is already struggling, each retry adds load and delays recovery.

A retry budget is the limit you place on that extra traffic before you write the retry logic. It has three parts: how many attempts you allow, how long you keep trying, and how much extra load your retries may add to the system. The goal is to absorb transient failures without amplifying sustained ones. When a service is overloaded, each retry makes it more overloaded, so the budget has to allow fewer attempts, shorter retry windows, or no retries at all.

You combine timeouts, exponential backoff with jitter, and circuit breakers into that budget for service-to-service calls, and you add client-side throttling when the budget is not enough. Exponential backoff means waiting longer after each failed attempt. Jitter adds randomness so clients do not retry in sync. A circuit breaker stops sending traffic to a service that keeps failing. By the end, you will know how to set the three numbers and where to put the safety valves.

Why retries amplify failures instead of fixing them

A retry is a second request, not a second chance. The downstream service does not know the request is a retry, so it spends the same CPU, memory, and I/O processing it again. Marc Brooker’s simulation of retry strategies makes the arithmetic concrete: with three retries at a 100% failure rate, the system does four times as much work as it would with no retries. As one analysis of retry storms puts it, a retry is not a second chance but a second request: the system did not become more reliable, it became three times louder while already struggling.

The amplification is worse than the per-request math suggests, because retries multiply across services. If a payment service goes down and 50 microservices each retry 10 times per second, they generate 500 extra requests per second, a [self-inflicted DDoS attack](https://google.com/goto?url=CAESpQEB6zswFbiCrZ2GpKVTl0poBn5vKWUHBfiAF2i5mbFyYGYdkmh_hDFcfGNDQCkTYnjRZCA15mghWFOnXTpepoprOMQCVgaifHfgRrNVfpSDOIoevcJO7soOa2_nWp8jqMAGa__6tcRWNlwhTiktbmLxsbeMQQ2PozX_wEZX5ugjll_tLO-3fFu1gOOp2r2mdrXNUJAHQgujaj7awWgOmYsVqcPIdRo. Google’s SRE team makes the same point at the platform level: retries can amplify a low error rate into a much higher level of traffic, which is how a small failure cascades into an outage. Latency grows the same way: a request that fails and retries three times takes at least the sum of the three attempts, and when the service is overloaded, each attempt takes longer than the last.

The thundering herd problem makes the timing worse. When a service fails, many clients fail at roughly the same time, so they retry at roughly the same time, and their requests arrive as a synchronized wave. The service, which has not recovered, spends its limited capacity rejecting the wave. Microsoft notes that retries within a short period are unlikely to succeed because the service has not recovered, and the excessive connection attempts during recovery can overwhelm it further. The same pattern shows up in telemetry as very long response times and repeated connection attempts, and services can struggle to recover even after the original fault is repaired. A client that retries indefinitely also wastes work, because requests remain valid only for a limited time. A client that retries minutes after the original request may operate on stale data or a dead session.

Retries can also duplicate side effects. If the operation is not idempotent, meaning running it twice does not produce the same result as running it once, the client can charge a customer’s credit card twice or create two orders. Azure advises you to avoid retrying non-idempotent operations unless the operation carries an idempotency key that lets the server recognize the duplicate.

The four controls: timeout, backoff, jitter, circuit breaker

Four mechanisms control how retries behave, and each one solves a different failure mode. A timeout bounds how long a single attempt may take. Exponential backoff spaces out attempts so the service gets time to recover. Jitter randomizes the spacing so clients do not retry in sync. A circuit breaker stops sending traffic to a service that is failing persistently, so retries do not continue indefinitely.

Timeouts come first because they bound the cost of every attempt. Without a timeout, a slow service can hold a client thread or connection open indefinitely, and a retry budget built on top of that is meaningless: one attempt can consume the whole budget. Set the timeout from the service’s normal latency distribution, not from the worst case you can tolerate.

Exponential backoff is the standard answer to how long to wait between attempts. Google’s SRE guidance requires exponential backoff with jitter for every client that makes an RPC, and Google’s IAM documentation gives the concrete formula: wait min((2^n + random-fraction), maximum-backoff), where n is the retry number, with a typical maximum backoff of 32 or 64 seconds and a deadline after which you stop retrying. The exponential part gives the service time to recover. The random part, the jitter, prevents the synchronized wave of retries known as the thundering herd problem. Azure says the same thing: the period between retries should spread requests from multiple instances as evenly as possible, so a busy service does not keep getting hit by all clients at once.

A circuit breaker handles the case where backoff is not enough. If a service is failing persistently, no amount of waiting will help, and a client that keeps retrying only adds load. The Circuit Breaker pattern stops new requests from reaching a failing service for a cooldown period, then lets a small amount of traffic through to test whether the service has recovered. Azure advises you to combine the Retry and Circuit Breaker patterns: retries handle transient faults, and the circuit breaker handles sustained ones. If a request still fails after many retries, the client should stop sending requests to that resource and report the failure immediately.

Setting a retry budget that fits the call

A retry budget has three numbers: the maximum number of attempts, the total time you are willing to spend retrying, and the fraction of your traffic that retries may represent. The first two are the ones you configure directly. The third is what the first two produce, and it is the number that determines whether you survive an outage. The controls from the previous section map onto these numbers: the timeout bounds each attempt, the backoff and jitter space the attempts out, the circuit breaker ends the sequence when the service is failing persistently, and the deadline caps the whole sequence.

Start with the total time because it is the easiest to justify. Microsoft’s Retry Storm antipattern notes that retrying for a few seconds or minutes is enough for most applications. The context a request carries goes stale: a user session expires, a lock is released, a cached value is invalidated. A client that retries after that context is gone wastes work. Set a deadline. When the deadline passes, fail the request and report the error. For noncritical operations, Azure recommends failing fast rather than retrying several times and dragging down the application’s throughput.

You control how much time you use through the attempt count and the backoff schedule. The AWS SDK for Java 2.x standard retry strategy retries 2 times for a total of 3 attempts, with a base delay of 100 ms for non-throttling exceptions and 1 second for throttling exceptions. It caps the delay at 20 seconds and uses circuit breaking to disable retries when downstream failures are high. DynamoDB clients use a higher default of 8 retries, a reminder that the right number depends on the service you are calling. The structure matters more than the specific numbers: a small number of attempts, a base delay that grows, a hard cap on the delay, and a circuit breaker that stops retries entirely when the failure rate is high.

The SDK also shows how to cap the load fraction. The standard and adaptive strategies give the client a token bucket of 500 tokens, a pool that refills over time and drains with each retry, and they charge 5 tokens per retry, so a client that burns through its bucket stops retrying until the bucket refills. The legacy strategy, which AWS has deprecated, charges 0 tokens for throttling retries, so throttling retries never drain the bucket. AWS says the legacy strategy fails to protect downstream services from retry storms and can lead to resource starvation on the client side.

The error type should also shape the budget. Microsoft is blunt: a 400 Bad Request indicates an invalid request from the client, and retrying the same request will not help. The same logic applies to any deterministic error: a validation failure, an authentication error, a request that is too large. Retry only the errors that could plausibly succeed on a second attempt: 500, 502, 503, and 504, as Google’s IAM documentation recommends, plus 404 where eventual consistency is the cause.

One more rule keeps the budget from leaking across layers: do not nest retries. If service A calls service B and both retry, A waits, retries, B waits, retries, and the caller of A waits through all of it, so the total delay grows much faster than either service’s own budget suggests. Azure advises you to make the lower-level task fail fast and report the reason back, so the higher level can decide whether a retry is worthwhile.

Throttling when the budget is exhausted

Retry budgets control what your clients do, but they do not control how many clients you have. When many services retry at once, their combined traffic can exceed the downstream service’s capacity even if each individual client is well behaved. Google’s SRE team solves this with client-side throttling: each client tracks its requests and accepts over the last two minutes, and when requests become K times as large as accepts, with a preferred multiplier of 2, the client starts rejecting new requests locally instead of sending them. The rejected request fails fast, the client does not spend a thread waiting, and the downstream service gets room to recover. Google’s guidance for cascading failures extends the same idea to the whole system: once total load exceeds total capacity, drop a fraction of traffic, including retries, upstream of the service.

The AWS SDK for Java 2.x adaptive retry strategy is the same idea packaged for AWS services. It includes everything in the standard strategy plus a client-side rate limiter that measures the rate of throttled requests compared to non-throttled requests and uses a dynamic backoff delay based on current load. The strategy assumes the client works against a single resource, one DynamoDB table or one S3 bucket, which is exactly the situation where a shared retry budget matters most.

Client-side throttling works only when the client has enough traffic to estimate the backend’s health. Google’s SRE guidance notes that sporadic clients have a drastically reduced view of backend state, so their estimates are noisy. Marc Brooker’s simulations show the same effect: with many clients each sending small volumes of traffic, per-client failure estimates vary widely, and a circuit breaker strategy can trip early, around half the expected failure rate, because each client is breaking independently.

The last line of defense is to make the backend resilient to excess traffic and to shed the least important work first. Google’s SRE guidance expects a backend provisioned to serve a certain traffic rate to keep serving at that rate without significant latency impact even when it receives 2x or 10x that rate. Google’s RPC system also propagates a criticality value on every request, CRITICAL_PLUS, CRITICAL, SHEDDABLE_PLUS, or SHEDDABLE, so a service under load can drop the shedable traffic before it drops the critical traffic. You can implement the same idea with a simpler mechanism: mark requests that can be dropped, and when the retry budget is exhausted, drop those first.

More in Web development Back to top ↑