Skip to main content
Deliberate AcademyProfessional AI Education
~16 min left
Lesson 7 of 10
16 min read10 XP

Shadow Deployments and Canary Releases for AI Features

Deliberate Academy Editorial Team

Reviewed for accuracy and professional relevance

You're 7 lessons in — don't lose your progress.

Sign up free
What you'll learn
  • Design a shadow deployment for an AI feature that runs a new model or prompt alongside production without serving its output to users, and explain what offline eval cannot detect that shadow mode can
  • Specify promotion criteria for a canary release of an AI feature — the quality thresholds that must be met before full rollout — and define rollback triggers for automatic and manual rollback
  • Apply traffic splitting at the model level, prompt level, and pipeline level, and explain when each split level is appropriate
  • Implement gradual rollout patterns for AI feature changes using feature flags

Offline evaluation tells you how a new model or prompt performs on your curated evaluation set. Shadow deployments and canary releases tell you how it performs on real production traffic — which is messier, more diverse, and more surprising than any evaluation set you can curate. Both stages are necessary: offline eval is the gate before shadow; shadow evaluation is the gate before canary; canary is the gate before full rollout.

This lesson covers the deployment patterns that allow you to validate AI changes under real conditions before exposing them to your full user base.

Shadow Mode for AI Features

A shadow deployment runs a new AI system component — a new model version, a new prompt, or a new pipeline configuration — in parallel with the current production system. Production traffic is duplicated: the real request is processed by the production system and its output is served to the user; the same request is also sent to the shadow system, but the shadow system's output is discarded rather than served.

Why shadow mode and not just offline eval. Offline eval uses a curated evaluation set that is, at best, a representative sample of production inputs. Shadow mode uses actual production traffic, which includes:

  • Input distributions you did not anticipate when curating the eval set
  • Seasonal or contextual variation in user intent
  • Inputs that are slightly out-of-distribution for your system
  • Newly popular query patterns that postdate your eval set curation

Shadow mode also reveals real-world latency and cost under production traffic patterns, which may differ from load test simulations. A shadow deployment is the highest-fidelity pre-launch validation available short of actual canary exposure.

Implementation architecture. The shadow deployment architecture duplicates each production request before it reaches the AI component. The cleanest implementation uses a request forking proxy or middleware layer that sends one copy of the request to the production AI system (synchronously, on the critical path) and one copy to the shadow system (asynchronously, off the critical path). The shadow system's output is written to a logging store for offline analysis rather than returned to the user.

The asynchronous shadow call must not block the production response. A shadow system that is slow, erroring, or in a degraded state must not degrade production latency or availability. Implement the shadow call with a strict timeout that is much shorter than the production call timeout, and discard the shadow result silently on timeout or error.

What to measure in shadow mode. Compare the shadow system's outputs to the production system's outputs on quality dimensions: quality score (using the LLM-as-judge from your eval framework), output length, output format compliance, failure rate (null outputs, schema violations, timeouts). Also measure operational metrics: latency distribution, cost per call, and error rate for the shadow system.

Shadow mode analysis answers the question: given production traffic, does the new system produce better, comparable, or worse outputs than the current system? If the shadow system produces consistently better quality scores on production traffic, it is a strong signal to proceed to canary. If quality scores are mixed — better on some input types, worse on others — the pattern of differences guides investigation and possibly further prompt tuning before canary.

Offline Eval vs. Online Eval

The distinction between offline eval (against a curated dataset) and online eval (against production traffic) is fundamental to understanding the role of each validation stage.

Offline eval is repeatable, cheap, and controllable. Run the same eval set against 10 different prompt variants and you get directly comparable results. The downside is that it is conditional on the eval set being representative of production — and it never fully is. Offline eval is appropriate for: initial development validation, CI regression gates, and A/B experiment analysis using pre-collected production data.

Online eval — evaluating model or prompt outputs on actual live traffic — captures the real input distribution but is not repeatable (you cannot replay the same inputs in the same order), is more expensive (you are scoring real API calls), and has real consequences if the evaluated variant is the one being served. Shadow mode is the form of online eval that avoids the consequence risk: you get production inputs but the shadow outputs are never served.

The validation ladder. The stages form a validation ladder where each stage provides higher-fidelity evidence at higher cost:

  1. Offline eval on curated dataset (lowest fidelity, lowest cost, earliest stage)
  2. Shadow deployment on production traffic (higher fidelity, higher cost, pre-canary)
  3. Canary release to small traffic fraction (highest fidelity, highest risk, pre-full-rollout)
  4. Full rollout (full production)
The validation ladder for AI releases, from offline eval to full rollout

Do not skip stages. A change that passes offline eval but skips shadow deployment and canary validation may reveal production distribution mismatches after full rollout — at which point remediation affects all users.

Traffic Splitting for LLM Experiments

Canary releases and A/B tests require traffic splitting: routing a defined fraction of production requests to the new variant while routing the remainder to the current production system.

Traffic splitting at the model level. Route a percentage of requests to a different model version (for example, 5% to gpt-4o-2025-10 versus 95% to the current pinned version). Model-level splitting is appropriate when evaluating a model upgrade. All other system components remain identical; the model is the only variable.

Traffic splitting at the prompt level. Route a percentage of requests to a different system prompt version while keeping the model constant. Prompt-level splitting is appropriate when evaluating a prompt change. This is the most common type of A/B experiment for teams that iterate frequently on prompts.

Traffic splitting at the pipeline level. Route a percentage of requests through a different pipeline configuration — for example, a new retrieval strategy in a RAG system, a different reranking approach, or a different chunking scheme. Pipeline-level splitting is appropriate when evaluating architectural changes that affect multiple system components simultaneously.

Consistent user assignment. For user-facing features, ensure that a given user consistently receives the same variant across their session and ideally across multiple sessions. Consistent assignment prevents confusing user experiences where the same feature behaves differently on sequential requests, and ensures that user satisfaction signals (ratings, complaints) are attributable to a specific variant rather than to variation within a session. Hash the user ID against the experiment ID to produce a consistent, deterministic variant assignment.

Promotion Criteria and Rollback Triggers

Before starting a canary release, define the promotion criteria and rollback triggers. Making these explicit before the experiment begins prevents the bias that arises from evaluating results after seeing them.

Promotion criteria. Promotion criteria define what the canary must achieve before you expand traffic to the next level (for example, from 5% to 25%, from 25% to 100%). A typical set of promotion criteria for an AI feature canary:

  • Primary quality metric (LLM-as-judge score, task completion rate, or similar): canary variant must meet or exceed production baseline by a defined margin, or achieve a defined quality floor
  • Guardrail metrics: latency p95 must not exceed production baseline by more than 20%; error rate must not exceed production baseline; cost per request must not increase by more than an acceptable percentage
  • Minimum observation period: at least 48 hours of data and at least 1,000 canary requests before any promotion decision, to ensure the data is not dominated by a single time period or user segment

Rollback triggers. Define the conditions under which the canary is immediately rolled back, without waiting for the full observation period:

  • Automatic rollback triggers: error rate exceeds a defined threshold for 15 consecutive minutes; p99 latency exceeds an absolute ceiling (for example, 30 seconds for a feature with a 10-second p95 baseline); any safety policy violation is detected in the canary outputs
  • Manual rollback triggers: quality metrics trending consistently below promotion threshold with no improvement; pattern of specific failure type emerging in canary outputs that was not seen in offline eval; on-call team judgment that the canary is producing a poor user experience even if aggregate metrics are above threshold

Feature flags for AI canary control. Implement canary traffic splitting via feature flags rather than by modifying the application code directly. Feature flag systems (LaunchDarkly, Unleash, or a custom flag service) allow you to change traffic percentages, rollback instantly, and target specific user segments — all without a code deploy. For AI features, a feature flag that controls which prompt version or model variant a user receives is the minimum viable canary infrastructure.

Tip

Define promotion criteria and rollback triggers in writing before the canary starts. Post-hoc promotion decisions — "the metrics look okay, let's proceed" — are subject to confirmation bias. Pre-committed criteria make the decision rule explicit and auditable, and prevent the pressure to ship from overriding safety thresholds that were set for good reasons.

Gradual Rollout Patterns for AI Features

A gradual rollout increases the traffic fraction to the new variant in stages, pausing at each stage to verify that metrics are stable before proceeding.

Stage structure. A typical gradual rollout for an AI feature change:

  • Stage 0: Shadow mode (0% of traffic served from new variant, 100% duplicated for offline analysis)
  • Stage 1: 5% canary (5% of traffic, 48-hour observation, check all metrics against criteria)
  • Stage 2: 25% canary (if Stage 1 criteria met, expand to 25%, additional 48-hour observation)
  • Stage 3: 50% canary (if Stage 2 criteria met, expand to 50%, 24-hour observation)
  • Stage 4: Full rollout (100%, previous variant remains available for emergency rollback for 48 hours)

The hold periods at each stage allow time for: daily traffic pattern cycles to complete (so you observe peak and off-peak behaviour at each stage), enough request volume to accumulate for statistical confidence, and on-call teams to monitor for emerging issues without alert fatigue.

Emergency rollback. After full rollout, keep the previous variant available for a defined period (typically 48 to 72 hours) before decommissioning it. An emergency rollback during this window should be possible within minutes: redirect all traffic back to the previous variant via the feature flag, without requiring a code deploy or infrastructure change.

Catching a production distribution mismatch via shadow deployment before a major model upgrade

AI Platform Engineer

Context

A financial services company operated an AI feature that extracted and classified line items from expense reports submitted by employees. The feature had been running on GPT-4o for eight months with stable quality metrics. The team was planning to migrate to a newer, faster, and cheaper model that showed comparable quality scores on their offline evaluation set of 300 expense report samples.

Action

The team did not proceed to canary. Instead, they used the shadow mode data to build a supplementary evaluation set with 60 additional non-English expense report examples, ran targeted prompt improvements against this category, and re-ran the shadow deployment with the improved prompt. The second shadow deployment showed consistent quality across all report categories, including non-English submissions. The canary proceeded with the improved prompt and model combination and reached full rollout without incidents.

Outcome

The shadow deployment identified a production distribution gap that the offline eval set had missed entirely. Without shadow mode, the regression would have been discovered in production, affecting thousands of expense reports before being caught. The two-week shadow mode period added two weeks to the release timeline but prevented a quality regression that would have required a rollback, root cause analysis, and prompt remediation under production pressure.

Knowledge check

A team has completed offline eval for a new RAG pipeline configuration and is planning to run a canary release. A project manager asks why shadow mode is necessary given that the offline eval already showed quality improvement. What is the most accurate response?

Select one answer.

Quick check

How must the shadow call be configured so that shadow mode cannot degrade the production path it runs alongside?

Select one answer.

Exercise

Your Task

You are the engineering lead for a team planning to release a new LLM model version for your AI customer support assistant. The current model (gpt-4o, pinned to a specific version) has been in production for six months. You want to test a newer model that shows improved quality in offline evaluation. Design the complete shadow-to-production release plan: (1) describe the shadow deployment architecture — how requests are duplicated, how shadow outputs are stored, and what is measured during the shadow period; (2) define the shadow observation criteria — what must be true about the shadow analysis before you proceed to canary; (3) specify the canary rollout stages with traffic percentages, observation periods, and promotion criteria at each stage; (4) define three rollback triggers — one automatic, two manual — with specific metric thresholds; and (5) describe the emergency rollback procedure and how long the previous model version will be kept available after full rollout.

Your reflection

Did you complete this exercise? What did you find? (Saved locally in your browser)

Key takeaways
  • Shadow deployments run a new AI variant alongside production using duplicated traffic, but discard the shadow output rather than serving it. They reveal production input distribution issues that offline eval datasets cannot capture.
  • The validation ladder for AI releases has four stages: offline eval, shadow deployment, canary release, and full rollout. Each stage provides higher-fidelity validation at higher cost. Do not skip stages.
  • Traffic splitting for AI experiments can be done at the model level, prompt level, or pipeline level. Consistent user assignment ensures that each user experiences one variant consistently, making satisfaction signals attributable to specific variants.
  • Promotion criteria and rollback triggers must be defined in writing before the canary starts. Pre-committed decision rules prevent confirmation bias from overriding safety thresholds under shipping pressure.
  • Feature flags are the minimum viable infrastructure for AI canary control: they enable instant rollback, traffic percentage adjustment, and user segment targeting without code deploys.