Try
↑ ↓ move↵ openesc close

Interview prep / Retries and circuit breakers

Mid · Retries and circuit breakers · System design interview question

What is a retry budget, and how is it different from limiting the attempts per request?

Sketch your own answer first, then compare it with the one below.

A strong answer

A limit on attempts per request caps retries for each request on its own, for example three tries in total. It sounds safe, but when the dependency fails, every request uses all of its attempts, so the load is multiplied by the limit.

A retry budget caps retries across requests. It might allow retries equal to a tenth of the recent requests. One way to build it is a token bucket: each new request adds a fraction of a token, and each retry costs a whole one. When the bucket is empty the client does not retry and the request fails immediately.

The result is that extra load is bounded by that fraction, however badly the dependency fails. During a blip, the budget is enough to retry the few failures. During an outage, it runs out and the client stops adding load.

The budget can sit per process or per client. A per-request limit is still useful for a single request that keeps failing. The usual practice is to use both.

Per-request limits multiply the load by the limit. A budget bounds it at the stated fraction.

Sources

Learn it by running it

The retries, timeouts and circuit breakers lesson explains the mechanism behind this question, and its lab lets you change the parameters and watch the effect.

Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms