The provider slowed down and your service fell over

L3SeniorDebug12 minDebuggingSystem design

RolesAI Evaluation and ReliabilityInference EngineeringLLM Product Engineering

The question

During a provider slowdown, the provider began to return rate-limit errors. Within minutes your own service ran out of memory and crashed, although your incoming traffic had not changed. Reconstruct what happened, and fix the retry policy.

Answer it first, aloud or on paper. Then open the answer.

The answer

Show short answer

The gateway retried every rate-limited call, and each waiting retry kept its connection, its buffers and its request state in memory. The retries multiplied the in-flight concurrency several times over the real traffic, and the memory went with it. Fix the policy with exponential backoff and jitter, a small fixed number of attempts, a cap on in-flight requests, and a fallback chain that fails over instead of waiting.

Show full answer

The chain of events

  1. The provider returns 429 for a share of the calls.
  2. The gateway retries each one. Each retry holds a connection, a buffer and the request state while it waits.
  3. In-flight requests become the traffic multiplied by the attempts. The chaos lesson names this retry-amplified concurrency.
  4. Memory follows the in-flight count, and the service that was healthy a minute ago runs out.

The retry policy in the production application capstone

Exponential backoff with jitter: wait about 1 second, then 2, then 4, with a random spread added to each wait, and give up after 3 retries with a fallback response. The lesson's table separates the cases:

FailureRetryFallback
429, rate limityes, with backoffqueue the request and tell the user it is in progress
500, server erroryes, 3 attemptsswitch to the fallback model
timeout over 30 secondsyes, 1 attempta shorter prompt or a smaller model

The jitter matters as much as the backoff. Without it, every client retries at the same instant and the provider sees a wave on each cycle.

Bound the concurrency, not only the attempts

Attempts bound the retries of one request. Nothing bounds how many requests wait at once. Add a cap on in-flight requests at the gateway and a retry budget as a share of traffic. When the cap is reached, fail fast into the queue or the fallback instead of holding memory.

The fallback chain

Primary model, then a secondary model, then a cached response, then a short unavailable message. Each step trades quality for availability, and the user always gets something.

Test it before the next slowdown

The chaos lesson's first model-specific experiment injects a provider rate-limit for a few minutes and watches the fallback. Most teams learn there that the fallback was never fully exercised.

Follow-ups

  1. L3SeniorWhy does backoff alone not stop the memory growth?

    Show expected answer

    backoff spreads the retries in time, and each waiting retry still holds its state. The fix needs a bound on in-flight requests.

  2. L3SeniorWhat does a queue do that a retry does not?

    Show expected answer

    it stores the request without a connection or a worker, and it gives the user a progress message instead of a timeout.

  3. L4StaffThe fallback model is cheaper and weaker. Who decides that it is acceptable, and how do you watch it?

    Show expected answer

    the product owner names the paths that may degrade. Log the fallback rate per path, and alert when it stays high.

Wrong answers

Show the wrong answers that interviewers hear
  • “Retry faster so the queue drains before memory runs out.”

    Faster retries raise the request rate against a provider that is already limiting you.

  • “Raise the maximum retries so users never see an error.”

    Each attempt holds memory. More attempts multiply the in-flight state.

  • “The provider caused the outage, there is nothing to fix here.”

    The provider caused the errors. The retry policy turned them into an outage.

Taught in

The production app lesson gives the backoff, the retry limits and the fallback chain, and the chaos engineering lesson names the retry storm as the failure to test.