Try
↑ ↓ move↵ openesc close

Interview prep / Retries and circuit breakers

Senior · Retries and circuit breakers · System design interview question

Design the client policy for two calls to the same slow dependency, a payment authorisation and a product search. How do the policies differ?

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

A strong answer

Start from what a failure and a duplicate each cost. A duplicate payment is expensive and a failed search is a nuisance, so the two get different policies.

For the payment, retries must be safe. Send an idempotency key so a repeat returns the first result. Use a longer timeout, since abandoning a call that was about to succeed leaves the outcome unknown, and a small attempt limit with backoff and jitter. If the outcome is still unknown, treat it as unknown: check the status before trying a different action. A breaker is useful, but its fallback must be an honest error and not a guess.

For the search, speed matters more than certainty. Use a short timeout and few or no retries. A retry that takes longer than the user will wait is useless. A fallback such as a cached or simplified result is good. A hedged request, which sends a second copy after a short delay and takes the first answer, can cut the tail, but only if the extra load is capped.

For both, share a retry budget and a breaker per dependency, pass deadlines down, and emit metrics on attempts per request, so a rise in amplification is visible before it becomes an outage.

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