Originally published on tamiz.pro.

According to recent reports, your AI gateway is the single point of failure for every LLM call in production. When it dies, your chat assistant, summarizer, and code copilot all die with it. The question isn't whether it will happen—it's whether you'll be ready. Most teams have no drill for LLM traffic; they have a vague runbook and hope. This tutorial fixes that. We'll build a complete incident response drill: SLOs, failure injection, automated runbook execution, and postmortem measurement. By the end, you'll have a repeatable practice that turns an AI gateway outage from a five-alarm fire into a well-rehearsed drill.

It has been revealed that traditional API gateways have mature incident practices. LLM gateways are different. They add latency, cost, and semantic degradation to the usual failure modes. A 503 from a REST endpoint is obvious; a 200 response that contains a truncated, hallucinated, or off-topic completion is not. Your on-call engineer needs to distinguish between a hard outage and a soft degradation—and the drill must exercise both.

Here are the failure modes you should plan for:.

"Who pages you?" is the core question. The drill answers it by forcing a real page, through your real alerting path, to a real on-call engineer (or a designated drill observer). If nobody gets paged, your monitoring is broken. If the page goes to the wrong team, your escalation is broken. The drill exposes these gaps before a real incident does.

Note: This tutorial assumes you have a basic understanding of Kubernetes, PromQL, and CI/CD. If you're new to SRE, check out Tamiz's Insights for foundational articles.

Here's the topology we'll build:.

In a recent development, the drill harness is a small service that can inject failures into the gateway. It exposes an endpoint like /fault/on and /fault/off. The gateway's middleware checks a shared flag (e.g., a ConfigMap or a Redis key) and, when enabled, returns a configurable status code (503, 429, or a timeout) for a percentage of requests. This keeps the injection decoupled from the gateway's core logic.

In a recent development, before you can drill, you need to know what "healthy" means. Define SLOs for your LLM traffic:.

It has been revealed that create a Prometheus recording rule for the success rate. Save as slo-rules.yaml:.

Sources indicate that now the alert rules. Save as alert-rules.yaml:.

Configure AlertManager to route severity="page" alerts to PagerDuty. The key here is that the drill will trigger these exact alerts, so you'll know the paging path works end-to-end.

We'll build a simple FastAPI service that toggles a fault flag in a shared ConfigMap. The gateway middleware reads this flag. This approach is clean, reversible, and doesn't require modifying the gateway's code—just adding a middleware wrapper.

In a recent development, first, the harness. Create drill-harness/main.py:.

Now the gateway middleware. Add this to your gateway's entrypoint (e.g., a FastAPI middleware or an nginx Lua script). Here's a Python middleware for a FastAPI-based gateway:.

Test it: curl -X POST http:///fault/on?status_code=503&rate=0.5 then hit the gateway—you should see a 50% failure rate. Then curl -X POST http:///fault/off.

A drill without a runbook is chaos. Write a concise, actionable runbook that lives in your repo (e.g., docs/runbooks/ai-gateway-outage.md). It should cover detection, triage, mitigation, and communication. Here's a template:.

The runbook must be executable. In the drill, the on-call engineer will follow these exact steps. If a step fails, you've found a gap.

Manual drills are fine for the first run, but you want them repeatable. Create a GitHub Actions workflow that runs the drill on a schedule (e.g., every Monday at 03:00 UTC) or on manual dispatch. The workflow should:.

Save as .github/workflows/ai-gateway-drill.yml:.

This workflow is a starting point. In a real drill, you'd want a human to acknowledge the page and execute the runbook. We can automate the injection and measurement, but the response should be human-driven—that's the point of the drill.

Industry observers note that now run the drill. Before you do, make sure you have a way to measure success. Define these metrics:.

Create a measurement script scripts/generate_drill_report.py:.

In a recent development, pro tip: Record the drill in a video or screen capture. Seeing your team's reaction to a real page is invaluable for postmortem review.

According to recent reports, after the drill, hold a postmortem within 48 hours. Answer these questions:.

Track these metrics in a drill-log.csv:.

The drill is not a one-off. Run it monthly, or at least quarterly, to keep the muscle memory fresh. As your LLM traffic grows, the drill will catch regressions in your monitoring and response before they become real outages.

Sources indicate that yes. If you're using a managed gateway (e.g., Azure OpenAI, AWS Bedrock), you can't modify its middleware. Instead, inject failures at the client side or at a proxy in front of the managed service. Deploy a lightweight reverse proxy (like Envoy or a simple nginx) that can return 503s based on a flag, and route all LLM traffic through it. The drill then targets the proxy. The key is to inject failures before the managed service, so your alerting and runbook paths are still exercised.

Industry observers note that start monthly. If your team is newly introduced to the runbook, run it every two weeks for the first quarter. Once TTD and TTM stabilize, you can move to quarterly. However, if you change your gateway, alerting, or provider, run a drill immediately after the change. The drill is a regression test for your incident response—it should be part of your release process for any infrastructure change.

Industry observers note that this is a real concern. Injecting failures at the gateway level doesn't directly cost LLM tokens—it returns errors before reaching the provider. But if your drill triggers fallback logic that retries against a secondary provider, you could incur costs. To mitigate: (1) set a hard budget for the drill in your CI/CD workflow (e.g., fail the drill if token spend exceeds $50), (2) use a mock provider for the drill if possible, or (3) cap the failure injection rate to 10–20% of traffic to limit retries. Always check your provider dashboard after a drill to confirm no unexpected spend.

It has been revealed that this tutorial is part of a series on production AI infrastructure. For more on SLOs, chaos engineering, and LLM observability, visit tamiz.pro and Tamiz's Insights.

📌 Read also:

→ Read original article