Contents
Key concepts
SLIs, SLOs and error budgets
An SLI is a measured ratio (requests answered successfully within 2 s ÷ all requests); an SLO is its target over a window (99.9% over 30 days); the error budget is what remains (0.1%, or 43.2 minutes of full outage a month). Spending the budget on risky launches is acceptable; exhausting it triggers a freeze on features in favour of reliability work. For LLM features use latency SLIs that match streaming (time to first token, inter-token latency) and add quality SLIs, such as schema-valid output rate and groundedness on sampled traffic, not just uptime: Anthropic’s 2025 postmortem describes weeks of degraded answers from routing, configuration and compiler bugs that error rates and standard benchmarks did not reveal, fixed in part by continuous quality evaluation on production.
Timeouts, retries, backoff and idempotency
Every call needs a timeout derived from the caller’s deadline; for streaming, use an idle timeout between chunks as well as a total one. Retry only transient errors (429, 503, timeouts), with exponential backoff and full jitter, honouring Retry-After. Retry at one layer of the stack, cap retries with a budget (for example, retries at most 10% of requests), and make side-effecting calls idempotent with idempotency keys so a retried refund is not paid twice. Restarts and reconnects need jitter too: Google Cloud’s June 2025 outage lasted longest in us-central1 because restarting tasks without randomised exponential backoff overloaded the database they all depended on.
Flow · 5 stepsClient-side resilience for a flaky LLM API
- Bound the call The caller sets a total deadline and an idle timeout between chunks.
- Call the provider The request reaches the LLM provider; a successful response returns the answer.
- Retry transient errors On 429, 503 or a timeout, retry with exponential backoff and full jitter, honouring Retry-After.
- Cap the retries Retries stay within a budget (for example at most 10% of requests); side-effecting calls carry idempotency keys.
- Fail fast to fallback Once the error rate crosses the threshold, the circuit breaker opens and traffic goes to a fallback model or a degraded response.
Data
| Step | Title | What happens |
|---|---|---|
| 1 | Bound the call | The caller sets a total deadline and an idle timeout between chunks. |
| 2 | Call the provider | The request reaches the LLM provider; a successful response returns the answer. |
| 3 | Retry transient errors | On 429, 503 or a timeout, retry with exponential backoff and full jitter, honouring Retry-After. |
| 4 | Cap the retries | Retries stay within a budget (for example at most 10% of requests); side-effecting calls carry idempotency keys. |
| 5 | Fail fast to fallback | Once the error rate crosses the threshold, the circuit breaker opens and traffic goes to a fallback model or a degraded response. |
Source: This page's text
| Box | Group | Detail |
|---|---|---|
| Incoming request | Input | caller deadline |
| Timeout guard | Client | total + idle timeout |
| LLM provider call | Provider | streaming |
| Retry with backoff | Client | exponential, full jitter |
| Circuit breaker | Client | fail fast past threshold |
| Answer | Output | success |
| Fallback / degraded response | Output | cheaper model, cached answer |
Source: This page's text
Overload protection and cascading failure
When a dependency slows, queues grow, timeouts fire, retries add load and healthy components fall over in turn. Defences: bounded queues and concurrency limits (semaphores), load shedding by priority, circuit breakers that fail fast once error rates cross a threshold, backpressure to callers, and graceful degradation (a cheaper model, a cached answer, a ‘try again shortly’ message). Metastable failures persist even after the trigger is gone because the retry load itself keeps the system overloaded; the fix is to remove the sustaining load. In AWS’s October 2025 us-east-1 outage, DynamoDB’s DNS was repaired in under three hours, but EC2’s lease manager then sat in congestive collapse trying to rebuild every lease at once and recovered only after engineers throttled incoming work and restarted its hosts selectively.
Tail latency at scale
With fan-out, the slowest component sets the response time: if each of 100 shards is slow 1% of the time, 63% of requests hit at least one slow shard. Mitigations include hedged requests (send a second copy after the 95th-percentile latency), tied requests, micro-partitioning and selective replication. Agent pipelines show the same arithmetic for correctness: 20 sequential steps at 95% success each complete only 36% of the time.
Fallbacks and vendor resilience
A single frontier-model API is a concentration risk. Put a gateway in front of providers, keep an evaluated fallback model (another provider or a self-hosted open-weight model) with prompts tested against it, and decide per feature whether degraded quality is acceptable. Check that ‘independent’ fallbacks really are independent: the same cloud region or the same underlying model behind two resellers fails together, and so do sibling models behind one shared service, as when a safety-filter configuration change broke every Gemini model on Vertex AI in February 2026.
Structured-output reliability
For JSON on every call, prefer constrained decoding or a provider’s strict schema mode over prompt- only instructions; validate with a schema library anyway, retry with the validation error once, and route persistent failures to a fallback or a queue. When about 2% of responses fail, bucket failures (truncation at max tokens, markdown fences, wrong types, refusals) by model version and input length before fixing anything.
Concurrency bugs and hung requests
Asynchronous clients need bounded concurrency (a semaphore), token-per-minute budgeting, cancellation that propagates, and no blocking calls (time.sleep) inside the event loop. Servers that hang under load but not alone usually point to resource exhaustion or a scheduling deadlock: KV cache full with preemption thrash, a pool with fewer slots than concurrent users (for example, adapter or connection pools), or an engine bug on a specific code path. Collect stack dumps and engine metrics while it is stuck, add per-request deadlines and a generation-based watchdog, and reproduce with a load test.
Minimum bar for production ML and continuous improvement
Before launch: reproducible training pipeline, data validation on training and serving inputs, offline evaluation with sliced metrics against a baseline, shadow or canary rollout with automatic rollback, monitoring of inputs, outputs and business metrics, an on-call owner and a runbook (the ML Test Score turns this into a rubric). Treat configuration and data pushes like code: Cloudflare’s November 2025 outage began with an internally generated feature file that doubled in size and crashed its proxy, so validate generated config as untrusted input, roll it out progressively and keep kill switches. After incidents: blameless postmortems with timelines, causes and owned action items, tracked to completion.
Worked examples
Retry amplification and a sane backoff policy
A request passes through three layers (API gateway → orchestrator → LLM client). Each layer makes up to 3 attempts. The LLM provider starts failing. At 200 incoming requests/s, how much load hits the provider? Then design a better policy with concrete backoff timings.
1. Amplification. Worst case, each layer multiplies attempts by 3: 3 × 3 × 3 = 27 provider calls per incoming request. At 200 requests/s that is 5,400 calls/s against a provider that is already struggling, which is how a partial outage becomes a full one.
2. Retry at one layer. Let only the LLM client retry; the upper layers fail fast and pass the error up. Worst case falls to 3× (600 calls/s).
3. Retry budget. Allow retries for at most 10% of requests in a sliding window: provider load is at most 1.1× (220 calls/s). If every layer must retry, each with a 10% budget, the bound is 1.1³ = 1.33× rather than 27×.
4. Backoff with full jitter. Base 0.5 s, cap 20 s; attempt n sleeps uniform(0, min(20, 0.5 × 2^n)).
- Retry 1: U(0, 1 s), mean 0.5 s.
- Retry 2: U(0, 2 s), mean 1 s.
- Expected extra wait for two retries ≈ 1.5 s; worst case 3 s. Jitter spreads clients so their retries do not arrive in synchronised waves.
- If the response has Retry-After, wait at least that long.
5. Circuit breaker. If the error rate exceeds 50% over 10 s, stop calling the provider for 30 s, send traffic to the fallback model or a degraded response, then let a few probe requests through before closing the breaker.
6. Streams. Use an idle timeout (for example, 15 s with no tokens) as well as a total deadline; on a stall, cancel and retry once from scratch if the remaining deadline allows.
Flow · 6 stepsRetry amplification and a sane backoff policy
- Amplification Each layer makes up to 3 attempts: 3 × 3 × 3 = 27 provider calls per request, about 5,400 calls/s at 200 requests/s.
- Retry at one layer The upper layers fail fast and pass the error up; only the LLM client retries, worst case 3× (600 calls/s).
- Retry budget Allow retries for at most 10% of requests in a sliding window; provider load is at most 1.1× (220 calls/s).
- Backoff with full jitter Base 0.5 s, cap 20 s; attempt n sleeps uniform(0, min(20, 0.5 × 2^n)); honour Retry-After.
- Circuit breaker If error rate exceeds 50% over 10 s, stop calling the provider for 30 s, send traffic to fallback or degraded response, then probe before closing.
- Streams Use an idle timeout (for example, 15 s with no tokens) plus a total deadline; on a stall, cancel and retry once if the remaining deadline allows.
Data
| Step | Title | What happens |
|---|---|---|
| 1 | Amplification | Each layer makes up to 3 attempts: 3 × 3 × 3 = 27 provider calls per request, about 5,400 calls/s at 200 requests/s. |
| 2 | Retry at one layer | The upper layers fail fast and pass the error up; only the LLM client retries, worst case 3× (600 calls/s). |
| 3 | Retry budget | Allow retries for at most 10% of requests in a sliding window; provider load is at most 1.1× (220 calls/s). |
| 4 | Backoff with full jitter | Base 0.5 s, cap 20 s; attempt n sleeps uniform(0, min(20, 0.5 × 2^n)); honour Retry-After. |
| 5 | Circuit breaker | If error rate exceeds 50% over 10 s, stop calling the provider for 30 s, send traffic to fallback or degraded response, then probe before closing. |
| 6 | Streams | Use an idle timeout (for example, 15 s with no tokens) plus a total deadline; on a stall, cancel and retry once if the remaining deadline allows. |
Source: This page's text
| Box | Group | Detail |
|---|---|---|
| Incoming requests | Input | 200 requests/s |
| API gateway | Layers | worst case 3 attempts; sane: fail fast |
| Orchestrator | Layers | worst case 3 attempts; sane: fail fast |
| LLM client | Layers | up to 3 attempts; the one retry layer |
| LLM provider | Provider | already struggling |
| Fallback / degraded | Fallback | after the breaker opens |
Source: This page's text
Can this LLM feature meet a 99.9% availability SLO?
A feature depends serially on an LLM API (99.5% available), a vector database (99.95%) and your own application tier (99.9%). What availability can it reach? What changes with a fallback provider that is also 99.5% available and fails independently?
1. Serial dependencies multiply. 0.995 × 0.9995 × 0.999 = 0.99351, about 99.35%. Over 30 days (43,200 minutes) that is 0.0065 × 43,200 ≈ 280 minutes of unavailability, against a 99.9% budget of 43.2 minutes.
2. Add an independent fallback provider. The LLM tier fails only if both fail: 1 − 0.005² = 0.999975. Overall = 0.999975 × 0.9995 × 0.999 = 0.99848, about 99.85%, or about 66 minutes a month. Better, but still over budget.
3. Where the budget goes now. The application tier alone (0.1%) consumes the entire 43.2-minute budget and the vector database adds 21.6 minutes. To reach 99.9% you must also harden those, for example multi-zone deployment for the app and a replica for the vector store, or relax the SLO.
4. Correlation caveat. If both providers run in the same cloud region, or one resells the other’s model, failures are correlated and the 0.999975 figure is fiction. Measure joint failure from incident history.
5. Degraded modes count. If a cached or smaller-model answer is acceptable during outages, define the SLI so degraded-but-useful responses count as available, and track quality separately.
CalculatorSerial availability against a 99.9% SLO
- Serial availability
- 99.35%
- Serial unavailable min
- 280 min/month
- Availability with fallback
- 99.85%
- Fallback unavailable min
- 66 min/month
Serial availability = LLM API availability × Vector database availability × App tier availability = 99.35%
Serial unavailable min = (1 − Serial availability) × 43200 = 280 min/month
Availability with fallback = (1 − (1 − LLM API availability) × (1 − Fallback availability)) × Vector database availability × App tier availability = 99.85%
Fallback unavailable min = (1 − Availability with fallback) × 43200 = 66 min/month
| Case | LLM API availability | Vector database availability | App tier availability | Fallback availability | Serial availability | Serial unavailable min | Availability with fallback | Fallback unavailable min |
|---|---|---|---|---|---|---|---|---|
| Worked example | 0.995 | 0.9995 | 0.999 | 0.995 | 99.35% | 280 min/month | 99.85% | 66 min/month |
Tail latency with fan-out, and what hedging buys
A request fans out to 100 retrieval shards and waits for all of them. Each shard is fast 99% of the time and slow 1% of the time, independently. What fraction of requests are slow? What happens if you send a hedged duplicate to another replica when a shard has not answered by its 95th-percentile latency?
1. Without hedging. P(no slow shard) = 0.99^100 = 0.366, so 1 − 0.366 = 63.4% of requests wait on at least one slow shard. The rare per-shard event becomes the common case.
2. With hedging. A shard is still slow only if the primary and the hedge are both slow: about 0.01 × 0.01 = 1e-4 if independent. P(at least one slow shard) = 1 − (1 − 1e-4)^100 ≈ 1.0%.
3. Cost. Hedges fire only for sub-requests slower than their p95, so extra load is about 5%. Cancel the loser when one copy answers.
4. Caveats. If slowness is correlated (a hot key, a shared overloaded host), hedging helps less; if the system is overloaded, hedges add load, so disable them under pressure. The same maths applies to agents: per-step success of 95% over 20 steps gives 0.95^20 = 36% end-to-end, so add verification and checkpoints rather than hoping each step improves.
Flow · 3 stepsFan-out tail latency and hedging
- Baseline fan-out Each shard is slow 1% of the time, so 0.99^100 = 0.366 and 63.4% of requests wait on at least one slow shard.
- Hedge after p95 A shard is still slow only if primary and hedge are both slow, about 0.01 x 0.01 = 1e-4, so about 1.0% of requests hit at least one slow shard.
- Cost and caveats Hedges fire only for sub-requests slower than p95, about 5% extra load; correlated slowness helps less, and hedges are disabled under pressure.
Data
| Step | Title | What happens |
|---|---|---|
| 1 | Baseline fan-out | Each shard is slow 1% of the time, so 0.99^100 = 0.366 and 63.4% of requests wait on at least one slow shard. |
| 2 | Hedge after p95 | A shard is still slow only if primary and hedge are both slow, about 0.01 x 0.01 = 1e-4, so about 1.0% of requests hit at least one slow shard. |
| 3 | Cost and caveats | Hedges fire only for sub-requests slower than p95, about 5% extra load; correlated slowness helps less, and hedges are disabled under pressure. |
Source: This page's text
| Box | Group | Detail |
|---|---|---|
| request | Input | fans out to 100 shards |
| fan-out | Fan-out | 100 retrieval shards |
| primary shard | Fan-out | fast 99% of the time |
| hedged duplicate | Hedge | second copy after p95 |
| wait for all | Fan-out | slowest shard sets response time |
| response | Outcome | cancel the loser |
Source: This page's text
What changed recently
One safety service took down every Gemini model on Vertex AI
On 27 February 2026 a configuration change to a safety-filtering service used by all Gemini models caused about two hours of errors on Vertex AI’s Gemini API, seen as 429s by pay-as-you-go customers and 503s by provisioned-throughput customers. It is a clean case of correlated failure behind apparently diverse fallbacks: switching to another Gemini model would not have helped, and a 429 did not mean the caller had exceeded its quota. Interviewers use it to test whether a fallback plan crosses providers and whether retry logic copes with provider-side faults.
Cloudflare's feature-file outage
On 18 November 2025 a database permissions change made a query write duplicate rows into the Bot Management feature file; the file passed a preallocated 200-feature limit and an unhandled error in Cloudflare’s Rust proxy turned into HTTP 5xx across its network, with core traffic restored about three hours later. Because the file was regenerated every five minutes from a partly updated cluster, the network flapped between good and bad states and first looked like an attack. The lessons interviewers probe: validate internally generated config like user input, stage global pushes and keep kill switches.
AWS us-east-1: a DNS race condition and congestive collapse
A latent race between two DynamoDB DNS automation workers left the regional DynamoDB endpoint with an empty DNS record. DNS was fixed in under three hours, but EC2’s lease manager, which depends on DynamoDB, then entered congestive collapse and network load balancers flapped on failing health checks, stretching impact to roughly 14.5 hours. It is a textbook metastable failure: recovery needed throttling and selective restarts, and AWS’s planned fixes include velocity limits on health-check failover and rate limiting by queue size.
Anthropic's postmortem of three quality bugs
Between August and early September 2025, a context-window routing error (up to 16% of Sonnet 4 requests in the worst hour, amplified by sticky routing), a TPU misconfiguration that corrupted token probabilities and an XLA:TPU miscompilation of approximate top-k degraded Claude’s output rather than causing errors. Noisy evaluations missed it and privacy limits slowed debugging; the fixes include more sensitive evals and continuous quality evaluation on production. Interviewers now ask how you would detect a model that is up but subtly wrong.
Silent data corruption in LLM training, measured on real faulty hardware
A study that trained on unhealthy nodes pulled from a production fleet, using deterministic execution to compare them with healthy ones, found that silent data corruption usually perturbs individual computations only slightly but can still push training to different optima and cause loss spikes. Questions about large training runs now go beyond checkpoint frequency to how you would detect corrupting hardware and when you would quarantine a node.
Pitfalls
- Retrying at every layer with no budget or jitter, turning a provider slowdown into a self-inflicted outage.
- Treating availability of a serial chain as the minimum of its parts instead of the product.
- Assuming fallback providers or models are independent when they share a region, cloud, underlying model or a hidden common service such as safety filtering, authentication, DNS or a CDN.
- Prompt-only JSON with no validation, or retrying a non-idempotent action without an idempotency key.
- Health checks that only test that the HTTP server is up, so a wedged model server keeps receiving traffic, and dashboards that track only errors and latency, so a model that is up but subtly wrong goes unnoticed.
- Postmortems that name a person as the root cause, or action items with no owner and no follow-up.
How interviewers probe it
- Your product depends on an external LLM API that returns 429s and sometimes stalls mid-stream: design the client-side resilience.
- Implement an async client with at most C requests in flight, a tokens-per-minute limit and backoff with jitter; how do you test it?
- Most of our AI features depend on one frontier-model API: is that a problem, and what would you do? Interviewers often anchor this on the 2025–26 cloud, CDN and model-provider outages.
- A self-hosted model server hangs at zero throughput under concurrent load but not for single requests: how do you debug it?
- What is your minimum engineering bar before an ML model goes to production, and how do you make tool-using agents reliable?
- Behavioural variant: something you inherited and improved, or a time you dug into details to find the real cause.
Quiz
Three questions from this guide. Answer each in your head or out loud, show the model answer, then rate yourself. The cards join your practice deck and come back when they are due.
Your product depends on an external LLM API that sometimes returns 429s and overload errors and occasionally stalls mid-stream. Design the client-side reliability layer.
Model answer, written in a candidate's voice
- Classify errors and retry only transient ones; honour Retry-After; backoff with jitter; bounded retry budgets.
- Set connect, TTFT and inter-chunk timeouts; cancel stalled streams and never treat partial output as success.
- Enforce client-side token buckets per model/provider/region and prioritize interactive traffic over batch.
- Use compatible fallbacks, circuit breakers, and graceful degradation such as cached answers or human handoff.
- Make side-effecting tool calls idempotent and instrument retries, latency, TTFT, gaps, fallbacks and breaker state.
Implement an async client that sends N prompts to an LLM API with at most C requests in flight, a tokens-per-minute limit, exponential backoff with jitter and per-request timeouts, returning results in input order.
Model answer, written in a candidate's voice
- Semaphore(C) bounds in-flight requests; token bucket refilled by elapsed time gates sends; estimate prompt+output tokens before sending and reserve/refund.
- Classify retryable vs non-retryable errors; exponential backoff with jitter and cap; honour Retry-After; max attempts.
- Index every prompt; collect results by index and return in input order; per-request timeout and cancellation; isolate exceptions per request.
- Return structured per-item results instead of raising the first failure; caller cancellation still propagates.
- Test with a fake server injecting 429s, latency, 5xx, malformed responses and slow bodies; assert concurrency, pacing, retries, timeouts, cancellation and order.
List the main ways tool-using agents fail in production and the mitigation for each.
Model answer, written in a candidate's voice
- Loops/stalls: step/time/token limits, repetition detection, progress checks
- Wrong tool/bad arguments: typed schemas, validation, examples, tool retrieval
- Claimed success without effect: verify state; ground final answers in tool outputs
- Cost/latency blow-ups: budgets, cheaper sub-models, caching, early stop
- Long-horizon drift: plan-then-execute, checkpoints, intermediate verification
- Injection/irreversible actions: untrusted outputs, confirmations, idempotency/dry-run/rollback
You have finished this topic.
Reading
- Postmortem Culture: Learning from Failure (Google SRE book, chapter 15)How blameless postmortems turn incidents into lasting improvements.
- A postmortem of three recent issues (Anthropic)How routing, configuration and compiler bugs degraded LLM output quality without raising errors, and why evals and privacy limits made them hard to catch.
- Service Level Objectives (Google SRE book, chapter 4)The canonical treatment of SLIs, SLOs and how to choose them.
- Timeouts, retries, and backoff with jitter (Amazon Builders' Library)Practical guidance on retry amplification across layers, jitter and idempotency.
- The ML Test Score: A Rubric for ML Production Readiness and Technical Debt ReductionA concrete checklist of tests for data, models, infrastructure and monitoring.
- Summary of the Amazon DynamoDB Service Disruption in the Northern Virginia (US-EAST-1) RegionA first-hand account of a latent race condition, a dependency chain and congestive collapse that needed throttling to recover.
- The Tail at ScaleWhy fan-out makes rare slowness common, and hedged or tied requests as remedies.
- Metastable Failures in Distributed SystemsExplains outages that persist after the trigger, often sustained by retries.
Practise this topic
- Your product depends on an external LLM API that sometimes returns 429s and overload errors and occasionally stalls mid-stream. Design the client-side reliability layer.
- Implement an async client that sends N prompts to an LLM API with at most C requests in flight, a tokens-per-minute limit, exponential backoff with jitter and per-request timeouts, returning results in input order.
- List the main ways tool-using agents fail in production and the mitigation for each.
- Your self-hosted model server is fine for single requests, but under concurrent load some requests hang at zero throughput while others finish. How do you investigate?
- Your pipeline needs JSON matching a schema on every call. Compare the options for guaranteeing it, and how you’d handle the failures that remain.
- Most of our AI features depend on a single frontier-model API. Is that a problem, and what would you do?
- Take a typical LLM serving stack: an API gateway, a request queue, a pool of GPU inference servers running continuous batching, and a single region behind a load balancer. What breaks under load, and what would you change first?
- How do you make tool-using agents reliable enough for production?
- What is your minimum engineering bar before an ML model goes to production?
- Design the serving stack for a large multimodal assistant used by millions of people. Where are the bottlenecks?