Quick revision
The short answer
Each layer retried on its own, so the attempts multiplied: 3 attempts at the gateway times 3 at service A times 3 at service B is 27 calls to the database path for every user request. When the database slowed down, that multiplied load kept it overloaded and turned a short slowdown into a retry storm and a full outage. We fix it by retrying at one layer only, adding a retry budget and circuit breakers so retries stop when a dependency is failing, honouring Retry-After, and always backing off with jitter.
What to remember
In this answer, we saw how three layers that each retried 3 times turned one user request into 27 database queries, and how that multiplied load created a retry storm that stopped the database from recovering. We fixed the policy by retrying at one layer, capping retries with a budget, opening a circuit breaker when the dependency is failing, honouring Retry-After, and backing off with jitter.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Each layer retried on its own, so the attempts multiplied: 3 attempts at the gateway times 3 at service A times 3 at service B is 27 calls to the database path for every user request. When the database slowed down, that multiplied load kept it overloaded and turned a short slowdown into a retry storm and a full outage. We fix it by retrying at one layer only, adding a retry budget and circuit breakers so retries stop when a dependency is failing, honouring Retry-After, and always backing off with jitter.
Why this question is asked
This incident is common and instructive, because every individual decision looked sensible. Each team added three retries to make its service more reliable, and together those retries made the system less reliable than having none. Interviewers ask it to see whether we can reason about the whole call chain rather than one service. In this answer, we will reproduce the arithmetic, follow how the extra load prevented recovery, and then fix the policy step by step: one retry layer, retry budgets, circuit breakers, and polite backoff.
1A Quick Recap of the Call Chain
A user request enters through the gateway, which calls service A, which calls service B, which queries the database. Each hop has its own HTTP client, and each client was configured to retry 3 times on a timeout. Retry configurations differ on whether 3 means three attempts or three retries after the first call. With three attempts per layer the numbers below hold; with three retries per layer it is 4 attempts per layer and 64 calls, which is even worse.
A timeout is the key ingredient. When the database slows down, B's queries take longer than A's read timeout, so A gives up and retries even though B is still working on the first request. The abandoned work keeps running, and the new attempt adds more.
2How Three Retries Became Twenty-Seven Calls
Let us count what one user request does when the database is slow and every call times out.
| Layer | Attempts here | Calls reaching the next layer |
|---|---|---|
| Gateway | 3 | 3 calls to A |
| Service A | 3 per call | 9 calls to B |
| Service B | 3 per call | 27 database queries |
Notice that the load on the database grows exactly when it is least able to cope. The slowdown might have lasted thirty seconds on its own, for example because of a vacuum or a lock held by a migration. Instead, the database received up to 27 times its normal load, its connection pool was exhausted, and queries that would have been fast became slow too.
3Why the System Could Not Recover
This is a retry storm: retries create load, the load causes more failures, and the failures cause more retries. It is a positive feedback loop. Three things kept it going. First, timed-out work was not cancelled, so the database kept processing queries nobody waited for. Second, retries at every layer were synchronised: without jitter, thousands of clients timed out together and retried together. Third, nothing ever stopped retrying, because no layer noticed that the dependency was failing for everyone.
So even after the original cause disappeared, the database stayed overloaded by the retry traffic alone. The outage ended only when someone restarted services or blocked traffic, which removed the retries.
- Database slows down30 s maintenance or lock
- Calls time out at Bwork keeps running
- Every layer retriesup to 27x load
- Pools and threads exhaustedfast queries become slow
- Load below capacity?YesSystem recoversNoMore timeouts, back to step 2
5 steps in order. Play them, or step through them one at a time.
4Fix 1: Retry at One Layer Only
The most important change is to choose one layer that retries. Usually that is the layer closest to the failure, service B's database client, because it knows which errors are transient and a retry there costs only one extra query. Sometimes it is the edge instead, when the client or gateway can retry an idempotent request against a different healthy instance. All other layers fail fast and pass the error up.
A common way to make this work across teams is to mark responses that have already been retried, or to agree that an error such as 503 from an inner service means do not retry. With one retry layer and 3 attempts, the worst case drops from 27 to 3 queries per user request.
5Fix 2: Retry Budgets and Circuit Breakers
Even 3 times the load can be too much for a struggling database. A retry budget caps retries as a share of normal traffic, for example retries may add at most 10 percent. When more than 10 percent of calls in the last few seconds were retries, further retries are skipped and the error is returned immediately. Envoy and gRPC have retry budgets built in, and in Java we can implement one with a counter in our client wrapper.
A circuit breaker goes further: once the failure rate passes a threshold, it stops calling the dependency entirely for a while and fails fast, then lets a few trial calls through to check recovery. In Resilience4j, the retry should ignore CallNotPermittedException so it does not retry against an open breaker.
With the breaker open, B answers in microseconds instead of holding a thread for a timeout, and the database gets breathing room to recover.
6Fix 3: Honour Retry-After and Back Off With Jitter
When an overloaded service answers 503 or 429 with a Retry-After header, it is telling us how long to wait. The client should wait at least that long instead of using its own shorter backoff. Every retry should use exponential backoff with jitter, so retries from many instances are spread out in time rather than arriving in waves.
Finally, timeouts should be consistent with the chain. The gateway's timeout must be longer than A's total time including its retries, and A's longer than B's, or the outer layer gives up while inner layers still work. Propagating a deadline header lets inner services stop work that nobody is waiting for any more.
7Follow-up questions
Which layer should own the retry?
Usually the one nearest the failing dependency, because it knows which errors are transient and a retry there is cheap. The edge is a good alternative for idempotent requests when it can send the retry to a different instance. What matters is that exactly one layer retries and the others fail fast.
How would you find this problem in metrics?
We would see the database request rate rising far above user traffic during the incident, retry counters climbing at every layer, and connection pool waiting threads at the maximum. A ratio of database calls to user requests going from 1 to 20 or more is the signature of multiplied retries.
Is removing all retries a good fix?
No. Retries do hide many short, real blips such as a pod restart. The fix is to keep a small number of retries at one layer, bounded by a budget and a circuit breaker, so they help with blips and switch off during real overload.
8Conclusion
In this answer, we saw how three layers that each retried 3 times turned one user request into 27 database queries, and how that multiplied load created a retry storm that stopped the database from recovering. We fixed the policy by retrying at one layer, capping retries with a budget, opening a circuit breaker when the dependency is failing, honouring Retry-After, and backing off with jitter.
Open with
What happened is retry amplification. Each layer retried independently, three attempts at the gateway, three at A and three at B, so one user request could become three times three times three, 27 queries at the database, or 64 if each layer did three retries on top of the first call.
Then, if they want more
When the database slowed down for a short time, requests timed out, but the timed-out queries kept running, and every layer retried at roughly the same moment because there was no jitter. The database got many times its normal load exactly when it was weakest, so it could not recover even after the original cause had passed.
That is a retry storm. To fix it, I would first make only one layer retry, usually B's database client, which is nearest the failure, and have the other layers fail fast.
Then I would add a retry budget so retries can add at most around ten percent of traffic, and a circuit breaker on the database dependency so that during a real outage we fail fast instead of piling up, with the retry configured to ignore CallNotPermittedException.
I would honour Retry-After on 503 and 429, use exponential backoff with jitter, and line up the timeouts so the gateway's is longer than A's and A's longer than B's, ideally with a propagated deadline. Then I would add a dashboard showing database calls per user request.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring Cloud documentation, Resilience4j documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "A short database slowdown caused a full outage: the gateway retries 3 times, service A...": https://scrivio-interview-library.netlify.app/spring-boot/resilience/05dc87a139/