Skip to content
intermediate Phase 18 · Production Capstone and Interview Prep

AI Deployment Checklist

Verify secrets, quotas, monitoring, rollbacks, and docs before a production launch.

55m
0 problems
Topic Progress 0%

Secrets and Quotas: What Pages You at 3 a.m.

Most AI outages trace back to two mundane causes: a key that leaked into a repository, or a provider quota that evaporated under real traffic. Both are checkable in an afternoon, and both are invisible until they fail.

Secrets first. API keys live in a secret manager and are injected at runtime — never in code, never in client bundles, never in environment files committed to the repo. Rotation is a documented procedure, not a hope: generate the new key, verify it, swap it, revoke the old one, and test the whole path before you need it under pressure.

import os

def load_config() -> dict:
    api_key = os.environ["LLM_API_KEY"]  # fails fast if the secret is missing
    return {
        "api_key": api_key,
        "model": os.environ.get("LLM_MODEL", "provider-default"),
        "max_retries": int(os.environ.get("LLM_MAX_RETRIES", "3")),
    }

os.environ["LLM_API_KEY"] raises immediately when the key is absent, so a misconfigured deploy fails at startup instead of on the first user request. Quotas second: confirm your provider limit is at least 3x your expected peak requests per second, and confirm the burst ceiling covers a retry storm. A quota exhausted at 10x traffic is a capacity problem, not a code problem — see Rate Limiting and Retry Policy for client-side protection.

The checklist item that catches both: run the pre-flight check as part of CI, not as a manual step before launch. A script that asserts the key loads from the environment, the model name is pinned, and the quota header exceeds your peak turns a 3 a.m. page into a failed build. Readiness you can automate is readiness you can trust.

Load Test with Realistic Prompts

Load testing with "hello" tells you nothing. Prompt size drives token count, latency, and cost, so the test corpus must be sampled from real traffic — including the long, messy prompts users actually send.

import asyncio, time

async def load_test(request_fn, prompts: list[str], concurrency: int = 50) -> dict:
    sem = asyncio.Semaphore(concurrency)
    latencies = []

    async def one(prompt: str):
        async with sem:
            start = time.perf_counter()
            await request_fn(prompt)
            latencies.append(time.perf_counter() - start)

    await asyncio.gather(*(one(p) for p in prompts))
    latencies.sort()
    return {
        "requests": len(latencies),
        "p50_ms": latencies[len(latencies) // 2] * 1000,
        "p95_ms": latencies[int(len(latencies) * 0.95)] * 1000,
    }

Input: 1,000 prompts sampled from production traffic, run at 50 concurrent. Output: p50 420ms, p95 1,900ms, zero errors. Read the p95, not the mean — the mean hides the tail where your users live. If p95 exceeds your latency budget, the fix is usually a smaller model tier, a cache, or a reranker budget, not more hardware. For where the time actually goes, see Profiling End-to-End Latency.

Concurrency deserves a deliberate number, not a guess. Start at your expected peak concurrent requests and hold it for ten minutes — a burst test that passes for thirty seconds tells you nothing about connection pools, queue depth, or whether your rate limiter engages before the provider's does. If errors appear only at high concurrency, the fix is client-side throttling, not a bigger quota.

Dashboards and Alerts Before the First User Arrives

You should learn about your own outage from your dashboard, not from a customer. Three metrics carry an AI feature: error rate, latency, and spend. Each gets a dashboard and an alert threshold before launch day.

def emit_metrics(request: dict, latency_ms: float, cost_usd: float) -> None:
    metrics.gauge("llm.latency_ms", latency_ms, tags={"model": request["model"]})
    metrics.gauge("llm.cost_usd", cost_usd, tags={"feature": request["feature"]})
    metrics.increment("llm.requests", tags={"model": request["model"], "status": request["status"]})
Metric Dashboard Alert threshold
Error rate requests by status code > 1% over 5 minutes
Latency p50 / p95 by model p95 > budget for 10 minutes
Spend cost per day per feature > 150% of forecast

Tagging cost by feature is what makes a blowout diagnosable: a runaway loop in one feature shows up as a spike in one tag, not as a mysterious rise in a fleet-wide total. See Metering Token Usage and Tracing LLM Calls for the full trace design.

Alert fatigue is the silent killer of observability: ten alerts that fire weekly train the team to ignore the eleventh. Every threshold above should page a human only when it needs a human — error rate and spend get pages, latency gets a ticket, and anything that recovers on its own gets a log line. The test is simple: if an alert has never been worth waking someone for, it is not an alert.

Rollback Paths and Runbook Docs

A bad prompt release is a matter of when, not if. The question is whether you can reverse it in minutes or in hours. Prompts and models are versioned artifacts — stored, reviewed, and promoted through the same pipeline as code — so "rollback" means flipping a flag, not redeploying.

Rollback steps, in order: (1) flip the feature flag to the previous prompt version; (2) watch the error rate and faithfulness dashboards for 10 minutes; (3) if the regression is in the model, pin the previous model version; (4) write the postmortem while the details are fresh.

The runbook documents this before launch, not during the incident: what the dashboards are called, where the flags live, who has permission to flip them, and what "done" looks like. A runbook written at 2 a.m. during an outage is a runbook with mistakes. For versioning practice, see Versioning Prompts in Codebases; for model fallback design, see Model Fallback and Degradation.

Test the rollback in staging before you need it in production. A flag flip that has never been exercised may point at the wrong environment, lack permission, or revert to a prompt version that no longer exists. The drill takes ten minutes and turns the runbook from a document into a verified procedure — the same reason you drill incidents before they happen.

Quiz

1. Why sample real prompts for load testing instead of a fixed short string?

Question 1 options

2. What does a p95 latency of 1,900ms mean?

Question 2 options

3. Why tag cost metrics by feature?

Question 3 options

4. What is the first step when a bad prompt release is detected?

Question 4 options

Flashcards

Question

Why must API keys live in a secret manager, not in code?

Answer

A key in a repository is exposed to anyone with read access and cannot be rotated without a redeploy; a secret manager injects at runtime and supports rotation.

Question

What does a load test with realistic prompt sizes validate?

Answer

Rate limits, latency budgets, and cost projections under expected peak traffic — none of which a short-string test exercises.

Question

Which three metrics need dashboards and alerts before launch?

Answer

Error rate, latency (p95), and spend per day.

Question

Why emit cost metrics tagged by feature?

Answer

So a runaway loop or abusive integration is attributable to one feature instead of hiding in a fleet-wide total.

Question

What is the fastest rollback path for a bad prompt release?

Answer

Flip the feature flag to the previous prompt version — no redeploy required.

Revision Notes

Key Takeaways

  • 1. Secrets and quotas are the two failure modes that are cheap to check and expensive to learn about in production
  • 2. Load test with realistic prompts and read p95, not the mean
  • 3. Dashboards and alerts for error rate, latency, and spend must exist before the first user arrives
  • 4. Rollback is a flag flip when prompts and models are versioned — document it before you need it

Interview Tips

  • • Present the checklist in the order an incident would expose it: secrets, capacity, observability, rollback
  • • Give concrete thresholds: 3x quota headroom, p95 budget, 150% spend alert
  • • Emphasize that the runbook is written before launch — interviewers probe whether you have operated systems
  • • Connect each item to a failure mode you have seen or can describe specifically

Cheat Sheet

AI Deployment Checklist — Cheat Sheet

Secrets & quotas

  • keys in a secret manager, injected at runtime, never in code
  • rotation procedure documented and tested before it is needed
  • provider quota >= 3x expected peak RPS; burst ceiling covers retry storms

Load test

  • sample real prompts from traffic, not fixed short strings
  • measure p50 and p95, not the mean
  • validate rate limits and latency budget at expected peak concurrency

Observability (before first user)

  • error rate: alert > 1% over 5 min
  • latency: alert p95 > budget for 10 min
  • spend: alert > 150% of forecast, tagged per feature

Rollback

  • prompts and models versioned behind feature flags
  • steps: flip flag → watch dashboards 10 min → pin model if needed → postmortem
  • runbook written before launch, not during the incident

Continue Learning

Before You Start

  • No prerequisites listed.

Related Reading