Lesson 8.4: Deployment and observability
Ship an AI feature and keep it running: versioned prompts, eval gates, retries and failover, rate limits and capacity, error budgets and a launch checklist.
A feature that works on your laptop and passes its evals is not yet a product. Between that point and a dependable service lie questions that have little to do with language models and a great deal to do with engineering: where does the code run, how are prompts and settings changed without breaking things, what happens when the model provider is slow or down, how do you stay inside rate limits when traffic spikes, how do you know the system is healthy at three in the morning and how do you decide when it is ready to launch? This final lesson of the track pulls together the practices that turn a working prototype into a service you can run with confidence. It builds on the evaluation and monitoring lessons of Module 6, the agent reliability ideas of Module 7 and the cost and safety lessons of this module. By the end you will be able to sketch the architecture of a production AI feature, treat prompts, models and settings as versioned and tested artefacts, build an eval gate into your release process, use timeouts, retries with backoff, fallbacks and circuit breakers, compute the availability of a chain of services with and without failover, check traffic against rate limits and plan capacity, define service targets and error budgets, and run a launch-readiness review. You should have read Lessons 6.1, 6.4, 7.4, 8.1 and 8.3. No programming is needed, and the arithmetic is multiplication and percentages.
The shape of a production system
A typical AI feature has these parts.
The client, a web page, an app or another service, which sends a request and shows the answer, usually streaming it.
A gateway or API layer, which authenticates the user, applies rate limits and passes the request on.
The orchestrator, your application code that builds prompts, calls retrieval, calls the model, runs tools and applies guardrails.
Model providers, external services, possibly more than one.
Data stores, such as the vector store, the database of documents and user data, a cache and a store for conversation state.
Tools and downstream systems, such as order systems or payment services.
Queues and workers, for slow or batch work that should not hold up the user, such as indexing a new document or running a nightly classification.
Observability, meaning logs, metrics, traces and dashboards, and an alerting system.
Configuration and secrets, including prompts, model names, limits and keys.
Draw this for your own feature, with arrows for every call. Every arrow is a place where something can be slow or fail, and the picture will show you where to put timeouts, retries and monitoring.
Treat prompts, models and settings as code
In an AI feature, behaviour is set by more than source code. The prompt text, the model and version, the temperature, the chunk size, the retrieval settings, the list of tools and the thresholds for declining all shape the answers. A change to any one can change quality, cost and safety, so each deserves the discipline that code gets.
Version control. Keep prompts and settings in files under version control, with reviews, not edited live in an admin page. Every change has an author, a date and a reason.
Versions in every request. Log the version of the prompt, the model, the index and the code with each request, as Lesson 6.4 advised, so that a change in behaviour can be tied to a change in the system.
Pin the model version where the provider allows it, and plan model upgrades as releases, with testing.
Environments. Keep development, staging and production separate, with fake or masked data outside production, and different keys.
Configuration, not code, for things that change often, such as thresholds, with the same review rules.
Secrets in a secrets manager, not in the repository or the prompt.
Reproducibility. Be able to rebuild any past version of the system, including its prompt and index, to investigate an incident.
The release pipeline with an eval gate
A release process for an AI feature adds one step that ordinary software does not have: the eval.
1. Change a prompt, a model, a chunk size or the code, in a branch.
2. Run the fast checks: unit tests for the code, format tests, linting and safety rules.
3. Run the eval set automatically, with the graders from Lesson 6.3, and compare against the current production version. Report the overall score, the slices, the cost per task and the delay.
4. Gate. The change may not merge if a key slice drops by more than an agreed margin, if safety cases fail, or if cost or delay rise beyond a limit. Use the noise estimates of Lesson 6.1, so that you neither block on chance nor wave through a real drop.
5. Deploy to staging, and run a smoke test of a few real flows.
6. Release gradually, with a canary, and watch the live signals, as in Lesson 6.4.
7. Roll back if signals go wrong, using a prepared and rehearsed procedure.
Running a large eval on every commit costs money and time, as Lesson 6.3 showed, so use a small fast set on every change and the full set before a release. The point is that no change reaches users without evidence.
Staying up: timeouts, retries, fallbacks
External services fail, and model providers are no exception. They can be slow, return errors, apply rate limits or go down. Your system should survive these events without hurting users.
Timeouts. Every call to an outside service needs a time limit, so that a hung call does not hold up the whole request. Choose the limit from the tail of normal delays, such as a little above the 99th percentile.
Retries with backoff. If a call fails for a temporary reason, such as a timeout or a rate-limit error, try again after a wait that grows: for example 1 second, then 2, 4, 8 and 16. Add some random variation, called jitter, so that many clients do not all retry at the same instant and overwhelm the service together. Do not retry errors that will not change, such as a malformed request. Cap the number of retries, since each adds delay and cost.
Idempotency. A retried request that triggers an action must not do it twice. Use idempotency keys, as in Lesson 7.1.
Circuit breakers. If a service fails repeatedly, stop calling it for a short time and fail fast, instead of piling up requests, and test it again after a pause.
Fallbacks. Have a plan B: a second model or a second provider, a smaller model, a cached answer, a simpler rule-based path or an honest message such as "I can't answer that right now". Test the fallback regularly, as an untested one often fails when needed.
Graceful degradation. If a part is down, such as the reranker, run without it and accept lower quality for a while, rather than failing the whole request.
Queues for non-urgent work, so that bursts are absorbed and processed at a steady rate.
Availability: how failures add up
A request passes through several services, and it works only if all of them work. For services in a chain, availability multiplies. Say the gateway is up 99.9% of the time, the vector store 99.9% and the model provider 99.5%. The chain is up 0.999 × 0.999 × 0.995 = 0.993, or 99.3%. A month has about 720 hours, and 0.7% of that is about 5 hours of downtime. Each component looks reliable, and yet the whole is down for most of a working day each month. This is the same multiplication that applied to the stages of a RAG pipeline and the steps of an agent.
Predict first: you add a second model provider as a fallback, with the same 99.5% availability, and assume that their failures are independent. What is the chance that both are down at once, and roughly how much downtime does the whole chain now have? Work it out before you read on.
Both are down together with probability 0.005 × 0.005 = 0.000025, so the model layer is available 99.9975% of the time. The chain becomes 0.999 × 0.999 × 0.999975 = 0.99798, or 99.8%, about 1.5 hours of downtime a month, down from 5. The failover removed most of the downtime caused by the weakest part.
The real figure will be somewhat worse, because failures are not fully independent: a network problem on your side hits both, and when one provider goes down, traffic that spills to the second may exceed its limits. A fallback that has never been tested does not count. But the principle holds: redundancy at the weakest link is the cheapest way to raise availability. It costs integration work and a possibly higher price or lower quality for the fallback, which you must weigh.
Rate limits and capacity
Model providers limit how much you may send: a number of requests a minute, tokens a minute, or both. If you exceed the limit, requests are rejected or slowed. Plan capacity with arithmetic.
Take a feature whose average request has 3,800 tokens in and out together. Suppose the provider allows 2,000,000 tokens a minute. The most requests per minute you can send is 2,000,000 ÷ 3,800 = about 526. If the busiest minute of the day brings 400 requests, you need 400 × 3,800 = 1,520,000 tokens a minute, which is 76% of the limit, leaving 24% headroom. If a campaign brings 600 requests in a minute, you need 2,280,000 tokens, which is 114% of the limit, and about one request in seven will fail or wait.
Ways to manage the limit: ask the provider for a higher limit well before a launch, spread load across providers or regions, queue non-urgent work to quieter periods, shorten prompts, cache repeated work, shed load gracefully in an overload by answering the most important requests first and set per-user limits so that one user cannot use up the allowance. Plan for peaks, not for the average, and test with a load test, using realistic traffic, before launch.
Service targets and error budgets
How do you decide whether a service is healthy enough, and how to trade reliability against the speed of change? A common method is to set service level objectives, or SLOs: specific, measurable targets for what users experience. Examples:
99% of requests return an answer, not an error, in a month.
95% of requests finish within 8 seconds.
90% of sampled answers are graded as faithful.
Each target implies an error budget: the amount of failure you can accept. If the SLO is 99% success over 1,000,000 requests in a month, the budget is 1%, or 10,000 failed requests. You can spend the budget on risky changes, since some failures will follow, and when it runs low you slow down and focus on stability. The burn rate says how fast you are using it. If 4,000 failures occur in the first 5 days of a 30-day month, the sustainable pace would have been 10,000 × 5 ÷ 30 = 1,667 failures, so you are burning at 4,000 ÷ 1,667 = 2.4 times the sustainable rate and will use the budget in about 12 days. A burn-rate alert catches this before the month is lost.
For AI features, include a quality SLO as well as availability and speed, such as the share of sampled answers that pass the judge, so that a drop in answer quality counts as an incident and not only a drop in uptime.
Observability in practice
Lesson 6.4 listed what to log and watch. Here is how it fits into a running service.
Metrics for rates, errors, delay percentiles, tokens, cost, cache hits, retries, fallbacks used and queue depths, shown on dashboards by feature and version.
Logs with a request identifier, versions, inputs and outputs, with privacy care as in Lesson 8.3.
Traces across the whole request, so that a slow answer can be traced to retrieval, reranking, a tool call or the model.
Alerts tied to the SLOs and to symptoms users feel, with owners and runbooks.
Dashboards for different readers: engineers want delays and errors, product owners want task success and satisfaction and finance wants cost per task.
Feedback collection from users, such as thumbs and reports, flowing into a queue that the team reviews.
Regular reviews of the worst traces, the failure causes and the cost trends, and a habit of adding what you learn to the test set.
The launch-readiness review
Before a launch, or a major change, run through a checklist and have someone other than the builder review it.
1. Quality. Evals pass on all key slices, including held-out cases, with margins that you understand.
2. Safety. Red-team tests run, guardrails in place and limits enforced in code, as in Lessons 7.4 and 8.3.
3. Privacy. Data flows documented, redaction measured, retention set, deletion possible and legal review done.
4. Performance. Delay targets met at the median and the tail under a realistic load test.
5. Capacity. Peak traffic within rate limits with headroom, and higher limits arranged if needed.
6. Reliability. Timeouts, retries, circuit breakers and a tested fallback.
7. Cost. Cost per task estimated and a budget alert set, with a cap on tokens, steps and spend.
8. Observability. Dashboards, logs, traces, alerts and runbooks ready.
9. Release. Canary plan, rollback procedure rehearsed and a kill switch.
10. People. Named owners, an on-call arrangement, a support path for users and a communication plan for incidents.
11. Documentation. What the feature does, its limits, how it was evaluated and who to ask.
12. Post-launch plan. What you will watch in the first week, and who reviews it.
Three worked examples
Example 1: a launch that hit the limit. A retailer launches an AI shopping assistant during a festival sale. The team had tested at 150 requests a minute. At the peak, traffic reaches 700 a minute, each request using about 3,800 tokens, a need of 2,660,000 tokens a minute against a limit of 2,000,000. About a quarter of requests are rejected, and users see errors. The team adds a queue and a short message for overload, asks the provider for a higher limit and routes simple questions to a cheaper model with its own limit. At the next sale, a load test at 1,000 requests a minute passes, and peak use is 70% of the combined limits.
Example 2: an eval gate saves a release. A team changes a prompt to make answers friendlier. The gate runs 300 cases and finds the overall pass rate unchanged at 88%, but the refunds slice falls from 90% to 74%, and a safety case that tests promises beyond policy fails. The change is blocked. The team adds a line to the prompt and two cases, reruns, and the refunds slice returns to 91%. The release goes out through a 5% canary and proceeds to full traffic after a day with no change in the signals. The bad version never reached users.
Example 3: failover during an outage. A provider has a two-hour outage. The circuit breaker opens after five consecutive failures and the system routes requests to a second provider with a slightly weaker model. Answer quality dips by about three points on the quality sample, delays rise a little and cost per request rises 20%, but the error rate stays under 1%. The dashboard shows "fallback active", the on-call engineer is paged only for the cost increase and the team reviews the episode the next day. Without the fallback, the feature would have been down for two hours, which would have used most of the month's error budget.
A deployment worksheet
1. The architecture. Every component and every call, with the failure of each.
2. The artefacts. Prompts, models, settings and indexes, with versions and owners.
3. The pipeline. Fast checks, eval gate, staging, canary and rollback.
4. The resilience. Timeouts, retries and backoff, idempotency, circuit breakers, fallbacks and degraded modes.
5. The availability. The chain, its multiplied availability and the weakest link.
6. The capacity. Peak requests, tokens per request, limits and headroom, with a load test.
7. The targets. SLOs for availability, delay and quality, with error budgets.
8. The observability. Metrics, logs, traces, alerts, dashboards and runbooks.
9. The launch review. The checklist, with an independent reviewer.
10. The first week. What you watch, who is on call and what triggers a rollback.
Common mistakes
Editing prompts live, with no version, review or test.
No eval gate, so changes reach users untested.
No timeouts, so one slow call holds up everything.
Retrying without backoff or limits, which causes retry storms.
An untested fallback.
Planning for average traffic, not the peak.
Ignoring rate limits until launch day.
Counting availability per service, not for the chain.
No quality target, so a drop in answer quality is not an incident.
Launching without a rollback plan or a kill switch.
Treating the launch as the end of the work.
Key takeaways
A production AI feature has a client, a gateway, an orchestrator, providers, data stores, tools, queues, observability and configuration. Each call is a place that can fail.
Treat prompts, models and settings as versioned, reviewed and tested artefacts, and log their versions with every request.
Add an eval gate to the release pipeline. A change that lowers a key slice or fails a safety case should not ship, and releases should go out gradually with a rollback.
Use timeouts, retries with exponential backoff and jitter, idempotency, circuit breakers, fallbacks and graceful degradation. Test the fallbacks.
Availability multiplies along a chain. At 99.9%, 99.9% and 99.5% the chain is up 99.3%, about 5 hours of downtime a month. A second independent provider cuts that to about 1.5 hours.
Check peak traffic against rate limits. At 3,800 tokens a request and a 2,000,000-token limit, 400 requests a minute use 76% and 600 use 114%.
Set SLOs with error budgets and burn-rate alerts, including a quality target. Run a launch-readiness review with an independent reviewer.
Check yourself
1. Three services in a chain are each up 99%. What is the availability of the chain?
0.99 × 0.99 × 0.99 = 0.970, or about 97.0%.
2. Why add jitter to retries?
Without random variation, many clients retry at the same instant and can overwhelm a recovering service. Jitter spreads the retries out.
3. A provider allows 1,000,000 tokens a minute. A request uses 2,500 tokens. What is the most requests a minute?
1,000,000 ÷ 2,500 = 400.
4. An SLO says 99.5% of 2,000,000 requests succeed in a month. How many failures does the error budget allow?
0.5% of 2,000,000 = 10,000.
5. Why should a change be blocked if a key slice falls, even when the overall score is unchanged?
An overall average can hide a large drop in one slice, as in the refunds example, which users in that slice would feel.
6. Why is an untested fallback risky?
It may fail when needed, due to configuration, limits or quality problems that nobody has seen, so the failover does not work during the outage.
Try this
Prepare a feature for launch. Set aside 90 minutes.
1. Choose an AI feature you run or plan, and draw its architecture with every external call.
2. For each call, write the timeout, the retry rule and the fallback.
3. Use the first simulator with your own availability figures to find the downtime of the chain, and what a second provider for the weakest part would give.
4. Estimate peak requests a minute and tokens per request, and use the second simulator to check the headroom against your provider's limit.
5. Write two SLOs, one for availability or delay and one for quality, with the error budget each implies.
6. Write the eval gate: which sets run, which slices matter and what drop blocks a release.
7. Complete the launch-readiness checklist, mark each item as ready, partly ready or not ready and name an owner for each gap.
A good result is an architecture sketch with failure handling for each call, an availability estimate with and without a fallback, a capacity check, two SLOs with budgets, a written eval gate and a launch checklist with owners for the gaps.
Tags: AI Engineering Deployment Observability Reliability LLM applications