How Front-End Retry Code Quietly Overloads Your API
A payments endpoint we run went dark for about 90 seconds on a Tuesday afternoon. The database failover did its job, the service came back healthy, and then it fell over again, harder, for eleven minutes.

A payments endpoint we run went dark for about 90 seconds on a Tuesday afternoon. The database failover did its job, the service came back healthy, and then it fell over again, harder, for eleven minutes. Nothing was wrong with the server the second time. The front end had been retrying the whole time, and when the door opened the retries arrived in one wave.
That shape turns up in most incident reviews I have sat through where a short blip became a long outage. The retry logic lives in the browser, written by whoever built the fetch wrapper two years ago, and nobody on the server team knows it exists until the request graph goes vertical. It is a front-end decision with a back-end bill, so it deserves more thought than the three lines it usually gets.
Why a 90 second blip turns into an 11 minute outage
Start with the arithmetic, because the arithmetic is the whole story. Say 4,000 people have your dashboard open. Each tab polls one endpoint every 30 seconds. Normal load is roughly 133 requests per second, which is nothing.
Now the endpoint starts returning 503. A retry wrapper with three attempts and a one second gap turns every failed poll into four requests. Load becomes 532 per second, four times the baseline, at the exact moment the service has the least capacity to answer. Worse, the failures line up. Every client that was blocked during the outage window fires at the same instant the health check flips green, so the first second after recovery carries a burst several times larger than steady state.
Connection pools fill, response times climb past the client timeout, and the clients that just timed out start their retry cycle again. That loop kept our payments endpoint down for eleven minutes after it was technically fine. The term for it is a retry storm, and it is self inflicted every time.
The wrapper everyone writes, and what it actually sends
The code is familiar enough that you can probably recite it. Wrap fetch in a loop, catch anything that throws or returns a non-2xx status, wait a bit, try again up to three times, then surface the error.
What it does not account for is how many layers are already retrying underneath it. One logical request can be attempted far more times than the code suggests:
- The browser itself retries an idempotent request once if a pooled HTTP connection is closed mid-flight. You never see it in the console.
- Your data layer retries. React Query defaults to three attempts on failed queries. Axios with the retry plugin commonly ships with three. Neither is off by default in most templates.
- Your fetch wrapper adds its own three.
- The user hits refresh, then hits it twice more, which resets everything.
- Window focus and reconnect handlers revalidate every active query the moment the laptop wakes from sleep.
Multiply layers two and three and one click becomes nine server requests. Add the focus revalidation on a tab that has been sleeping and you get bursts with no user action behind them at all. I have watched an access log where a single session produced 61 requests to one endpoint inside 40 seconds, and the person at the keyboard had pressed one button.
Backoff without jitter solves half the problem
Exponential backoff is the standard answer, and it is a real improvement: wait 1 second, then 2, then 4, then 8. Each client spaces out its own attempts, so the sustained load during an outage drops a lot.
It does nothing about synchronization, though, and synchronization is what breaks the recovery. If 4,000 clients all hit their first failure within the same second, pure exponential backoff means all 4,000 retry at second 1, all of them again at second 3, again at second 7. You have traded a flat flood for sharp spikes, and the spikes land at predictable moments.
Jitter fixes that. Instead of waiting exactly 2 seconds, wait a random duration between zero and 2 seconds, then between zero and 4, and so on. The maths here is well documented: full jitter spreads the same number of attempts across the whole window, so the peak concurrent load falls by roughly the factor you spread over. Two lines of code, and the recovery spike flattens.
A cap matters as much as the curve. Without a ceiling, a tab left open overnight ends up waiting 68 minutes between attempts, which looks identical to a broken page. Cap the delay at 30 seconds and cap total attempts at four or five. Past that, stop and tell the user, because a sixth automated attempt has never once fixed anything that attempts two through five did not.
The advice to retry on failure is mostly wrong
Every tutorial I can find treats "the request failed, so retry it" as the rule. That is the part I would push back on hardest. Most failures should never be retried, and retrying them is how you turn a clean error into a data problem.
A 400 means the payload is malformed. Sending it four more times will not improve the payload. A 401 or 403 means credentials, and hammering an auth endpoint is a reliable way to get the user's account rate limited or locked. A 404 means the resource is not there. A 409 means someone else changed the record first, which needs a human decision, not a loop. A 422 means validation failed. None of these are transient, and retrying them wastes capacity you need for the requests that are worth retrying.
The short list worth an automatic retry: network errors where no response arrived at all, 408 request timeout, 429 too many requests, and 502, 503 and 504 from a gateway or an overloaded origin. Nothing else.
Method matters just as much. A failed GET is safe to repeat. A failed POST is not, because a network error after the server committed the write looks exactly like a network error before it. Retry that POST and you get two charges, two orders, two support tickets. The fix is server side: an idempotency key the client generates once per logical action and reuses on every attempt, which is the same mechanism described in our piece on how idempotency keys stop duplicate API requests. Without that key in place, a retry on a write is a bug you have not found yet.
And when the server sends Retry-After on a 429 or 503, that header is not advisory. It is the service telling you precisely when it will be ready. Honour it and ignore your own backoff schedule for that attempt. Most client libraries throw it away, which is why rate limiting so often fails to calm traffic down the way the server team expected when they added it.
What to change in an afternoon
Open your network panel, set throttling to offline, click through your busiest screens and count the requests. That number is usually the surprise.
Pick one place for retry logic and delete it everywhere else. If React Query owns retries, your fetch wrapper should not add any, and vice versa. Two layers of three attempts is nine, and nobody designed nine.
Add full jitter and a 30 second cap. Restrict retries to idempotent methods and the six status codes above. Read Retry-After when it is present. Attach an AbortController with a timeout to every request, because a request with no timeout can sit open for two minutes and hold a connection slot the whole time, which is the same queueing behaviour covered in our explainer on how browsers limit connections and queue your requests.
Then turn the polling down. Polling every 30 seconds for data that changes twice an hour is the largest single source of pointless load in most dashboards I have looked at. Lengthen the interval, pause it when the tab is hidden with the visibilitychange event, and let focus revalidation handle the rest. There is more on taming event driven request volume in the front-end section.
One honest caveat: I have no clean measurement of how much this helps on mobile networks, where packet loss makes genuine transient failures far more common than on a wired office connection. The settings above are tuned for the server's survival, so if your users live on patchy mobile data you may want a more patient client than I would pick.
Frequently asked questions
How many times should a front-end request retry?
Three to five attempts total, including the first, with exponential backoff and full jitter, and a delay capped around 30 seconds. More than that does not recover requests that the earlier attempts missed, and it meaningfully increases load on a service that is already struggling.
Should I retry a POST request?
Only if the endpoint accepts an idempotency key and you send the same key on every attempt. Without one, a network error that arrives after the server committed the write is indistinguishable from one that arrives before, so a retry can duplicate a payment or an order.
What is a retry storm?
A traffic surge caused by many clients retrying at the same time. It usually follows a brief outage: clients blocked during the failure all fire together on recovery, which overloads the service again and triggers another round of retries. Jitter and attempt caps are the standard defence.
Does exponential backoff need jitter?
Yes, if more than a handful of clients are involved. Plain exponential backoff keeps clients synchronized, so they retry in tight spikes at second 1, 3 and 7. Randomizing each delay spreads the same attempts across the window and flattens the peak.
More in Front-End
Front-End
How to Find the Element Causing Horizontal Scroll
A tester filed a bug last March that said "page wobbles sideways on my phone". No screenshot, no device model.
Front-End
Why z-index Stops Working: Stacking Contexts Explained
The dropdown menu opens, and half of it disappears behind the hero image below. You give the menu z-index: 10 . Nothing.
Front-End
Event Delegation in JavaScript and When to Use It
You render a list of 300 rows, attach a click listener to each delete button, and everything works until new rows arrive from...