Backend & Node.js · APIs, data and failure

How do retries and backoff work without making an outage worse?

MediumretriesbackoffreliabilityUpdated Oct 2026
Quiz this track

Short answer

Retry only transient failures, use exponential backoff with jitter, cap attempts and total time, and respect Retry-After. Retries must be idempotent and limited by a budget, otherwise they amplify load during an outage.

A retry helps when a failure is temporary: a connection reset, a timeout or a 503. It hurts when the failure is permanent or when every client retries at once. The goal is to recover from transient faults without creating a retry storm.

js
async function withRetry(fn, attempts = 4) {
  for (let attempt = 0; attempt < attempts; attempt += 1) {
    try {
      return await fn();
    } catch (error) {
      if (!isRetryable(error) || attempt === attempts - 1) throw error;
      const base = 100 * 2 ** attempt;
      const delay = base + Math.random() * base;
      await new Promise((resolve) => setTimeout(resolve, delay));
    }
  }
}
Jitter spreads retries across clients. The cap on attempts prevents an unbounded loop.

Rules

  • Retry timeouts, connection resets, 429 and 502 or 503, not 400 or 422
  • Use exponential backoff with full or decorrelated jitter
  • Respect Retry-After when the server provides it
  • Cap total attempts and total elapsed time
  • Make the operation idempotent or pass an idempotency key
  • Limit retries as a fraction of traffic so an outage does not triple load

Retries stack across layers. A client retries the gateway, the gateway retries the service, and the service retries the database, multiplying the original request. Decide where retries belong, usually one layer close to the failing dependency, and make the others fail fast.

Do not retry inside a loop that holds a database transaction or a lock. Release the resource first, then back off, or the retry will extend the original contention.

Follow-ups you should expect

Interviewers use these to check whether the first answer was understanding or memorisation.

  1. 1Which errors should not be retried?
  2. 2Why is jitter important?
  3. 3How do retries interact across service layers?
  4. 4When should you respect Retry-After?

Say it in the interview

I retry only transient failures and use exponential backoff with jitter, a bounded attempt count and a total time limit. The operation must be idempotent or carry an idempotency key, and I respect Retry-After from the server. I also decide which layer owns retries, because retries at every layer multiply load during an outage. A retry is a resilience tool, not a default for every error.

Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.

Related questions

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Backend & Node.js mock interview and get scored feedback on depth, clarity and confidence.