Reliable requests · mid
Retries with exponential backoff, Retry-After and limits
Retry only failures that are likely temporary (network errors, 408, 429, 500, 502, 503, 504), only for idempotent requests or ones with an idempotency key, with exponential backoff plus jitter, respecting Retry-After, and with a small maximum so retries do not overload a struggling server.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Retryable: network errors and timeouts, 408, 429, 500, 502, 503, 504. Not retryable: 400, 401 (refresh the token instead), 403, 404, 409, 422.
- Retry GET/PUT/DELETE freely; retry POST only with an Idempotency-Key.
- Backoff: wait base x 2^attempt (200, 400, 800 ms...), add jitter, cap it, and stop after 2 to 4 retries. Honour Retry-After (seconds or a date) on 429 and 503.
- Use a per-attempt timeout (AbortSignal.timeout) and an overall deadline, so a retry loop can't hang for minutes.
- Protect the server: retry budgets (for example at most 10% extra requests), circuit breakers that stop calling a failing service for a while, and no retries at several layers at once (client + gateway + service multiplies load).
- UX: show 'Retrying...' for long waits, keep user input, and offer a manual retry button after automatic retries fail.
The red pen
Common traps: mistake → fix
Mistake: "Retry every failed request 5 times immediately"
Fix: it multiplies load on a failing server and fails 5 times faster.
Mistake: "Retry POST /orders on timeout"
Fix: without an idempotency key you may create duplicate orders.
Mistake: "Retry 4xx errors"
Fix: they fail again; only 408 and 429 are worth retrying.
Easy to hard
Questions interviewers ask, easy to hard
- Write fetchWithRetry(url, { retries, backoff }). Which errors would you retry?
- Why exponential backoff, and why jitter?
- How do Retry-After and 429 change your logic?
- Design the retry and throttling contracts for a JS SDK used by many teams.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.