Inference, Serving & Production·Question 10 of 76Basic

Your app is getting 429s from your LLM provider at peak traffic. How do you handle rate limits properly?

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

Layered answer - immediate handling, then prevention, then architecture:

Immediate handling: retry with exponential backoff + full jitter (sleep = random(0, min(cap, base × 2^attempt))). Jitter is non-negotiable: without it, all throttled clients retry in synchronised waves and re-spike the provider (thundering herd). Respect the Retry-After header when present. Cap attempts (2-3) and enforce a retry budget - if more than a few percent of traffic is retrying, stop retrying and shed instead, or you amplify the overload. Distinguish error classes: 429 and 5xx are retryable; 400/422 (bad request, context too long) will never succeed - fail fast.

Full worked answer

Layered answer - immediate handling, then prevention, then architecture:

Immediate handling: retry with exponential backoff + full jitter (sleep = random(0, min(cap, base × 2^attempt))). Jitter is non-negotiable: without it, all throttled clients retry in synchronised waves and re-spike the provider (thundering herd). Respect the Retry-After header when present. Cap attempts (2-3) and enforce a retry budget - if more than a few percent of traffic is retrying, stop retrying and shed instead, or you amplify the overload. Distinguish error classes: 429 and 5xx are retryable; 400/422 (bad request, context too long) will never succeed - fail fast.

Prevention: rate limits are usually RPM + TPM (tokens/min) + concurrency. Track your own consumption client-side and gate with a token-bucket/semaphore before hitting the API, so you queue internally rather than burning requests into 429s. Prioritise traffic classes: interactive user requests get capacity first; background jobs (evals, enrichment) yield, or move to the batch API entirely - that's often the real fix, since offline work is what commonly eats the quota.

Architecture: request higher limits or provisioned/committed throughput for the baseline; spread across regions/accounts where the provider's terms allow; add a fallback chain (same model on another provider/cloud, or a smaller model) behind a circuit breaker for sustained throttling; smooth bursts with a queue and honest UX for non-interactive features.

Also instrument it: 429 rate, retry rate, queue depth, and time-to-success should be on a dashboard - chronic 429s are a capacity-planning signal, not an error-handling problem.

What a good answer covers

  • Immediate handling: retry with exponential backoff + full jitter (sleep = random(0, min(cap, base ×…
  • Jitter is non-negotiable: without it, all throttled clients retry in synchronised waves and re-spike the…
  • Respect the Retry-After header when present
  • Cap attempts (2-3) and enforce a retry budget - if more than a few percent of traffic is retrying, stop…
  • Distinguish error classes

Key terms: Immediate handling · exponential backoff + full jitter · retry budget · Prevention · Architecture · fallback chain

Interviewer follow-ups to expect

  1. Why is full jitter better than plain exponential backoff?

  2. Your retries are succeeding but P99 latency tripled - what's happening and what do you change?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep