CLOUD CONCEPT

Shadow Testing

Shadow testing evaluates a candidate system using copies of live production requests while only the established production system returns responses to users.

Cloud Concepts Hub →

What is Shadow Testing

A shadow deployment runs a candidate model or application alongside the production version, allowing engineers to compare behavior under real workloads without exposing users to candidate responses. It supports safer release decisions by revealing quality regressions, latency problems, errors, and resource requirements before a production traffic shift.

Shadow testing separates evaluation from serving decisions. The production system continues handling user requests, while a copy of some or all requests is sent to a candidate implementation, often called a shadow variant. The candidate executes the workload, but its responses are retained for evaluation rather than returned to users. This makes shadow testing useful for validating new machine learning models, inference containers, preprocessing code, or infrastructure configurations against realistic inputs.

In the cloud, request duplication can occur in an application gateway, a proxy, application code, or a managed inference service. Engineers provision the candidate with its own compute capacity, define a representative sampling policy, and collect outputs and operational measurements. The duplication path should avoid making the user request wait for the shadow response. Separate capacity, bounded queues, and timeouts help prevent a slow candidate from affecting production availability.

Useful comparisons require more than observing whether the candidate returns a successful response. Record correlation identifiers, model versions, relevant feature versions, and timestamps so that production and shadow results can be matched. Compare prediction disagreement, score distributions, error rates, throughput, resource utilization, and percentile latency. Use equivalent measurement boundaries when comparing latency, and account for differences in hardware, request volume, concurrency, and warm-up behavior. A lightly sampled candidate does not demonstrate that it can handle the full production workload.

For example, a payment-risk service can mirror a sample of transaction requests to a new classifier while the existing classifier continues making decisions. Engineers compare scores and later join predictions with confirmed fraud outcomes to evaluate precision, recall, and business cost. Disagreement with production is not proof that the candidate is worse: production predictions are a baseline, not ground truth. Labels can arrive late, and production decisions may influence which outcomes become observable.

For a foundation model application, shadow requests can help compare response latency, token consumption, formatting compliance, and safety behavior. Different generated wording is not necessarily a regression, so evaluation needs task-specific scoring, human review, or validated automated evaluators. External tool calls and other actions must be disabled or redirected to an isolated environment. Discarding a response does not prevent the candidate from sending an email, charging a payment, or modifying a database.

An automated delivery pipeline can deploy an approved candidate as a shadow, collect evidence over a defined observation window, and apply release gates. Gates might require sufficient samples, acceptable error rates and tail latency, and no material degradation on labeled quality metrics or important customer segments. A passing candidate can then proceed to a canary or blue/green rollout. A failing candidate should stop progressing and have its shadow traffic disabled or its deployment removed.

Shadow testing is not A/B testing or a canary deployment: those approaches expose some users to candidate responses and can measure resulting user behavior. Shadow testing cannot directly establish business impact when users never see the candidate output. It also adds inference cost and duplicates potentially sensitive data, requiring appropriate access controls, encryption, retention, and regional handling. After promotion, monitoring and rollback remain necessary because a successful shadow test does not guarantee production success. Preserve the previous model and deployment configuration, define rollback thresholds, and automate reversion where supported; do not assume that shadow testing itself provides rollback.

Key aspects of Shadow Testing

Shadow testing combines realistic traffic, isolated execution, evidence-based comparisons, and deployment gates to reduce release risk without serving candidate responses to users.

Live traffic without candidate responses

Send copies of production requests to the candidate while keeping the established version responsible for user-facing responses. Isolate request duplication so shadow failures do not become failures in the production request path.

Paired, reproducible comparisons

Correlate production and shadow predictions using request identifiers and record model and feature versions. Evaluate prediction differences alongside error rates, latency percentiles, and resource use.

Quality evaluation beyond agreement

Treat production output as a comparison baseline rather than a correct answer. Use ground-truth labels, task-specific evaluators, and segment-level analysis to determine whether the candidate actually improves quality.

Representative workload coverage

Choose a sampling rate and observation period that cover important request types, traffic peaks, and uncommon cases. Account for reduced load and different infrastructure before drawing capacity or latency conclusions.

Side-effect and data isolation

Prevent shadow execution from changing production state or triggering real-world actions. Apply privacy, access, and retention controls to duplicated requests and stored outputs.

Automated promotion and rollback readiness

Use explicit evaluation gates to decide whether a shadow candidate can advance to a user-facing rollout. Remove failing shadows without changing production routing, and retain a tested rollback path for any later production promotion.

Cloud services for Shadow Testing

CodePipeline can initiate a controlled release process, while Step Functions coordinates deployment, observation, evaluation, and cleanup. SageMaker AI provides managed inference endpoints with production and shadow variants for supported configurations. Captured inference records and evaluation reports in Amazon S3 support paired output analysis and later joins with ground-truth outcomes. CloudWatch supplies operational visibility and alarms. Together, these services can implement an evidence-driven promotion workflow, but engineers must define quality thresholds, isolate side effects, and explicitly configure failure handling and post-promotion rollback.

Amazon SageMaker image Amazon SageMaker

SageMaker AI supports shadow variants on supported real-time inference endpoints, duplicating a configured proportion of requests sent to a production variant without returning shadow responses to callers. Configure inference data capture and monitoring to compare outputs and operational metrics before promoting a candidate.

Open Amazon SageMaker →
Amazon CloudWatch image Amazon CloudWatch

CloudWatch provides metrics, logs, dashboards, and alarms for observing production and shadow execution. Use service metrics and custom evaluation metrics to detect errors, latency regressions, or resource pressure; connect alarms to deployment orchestration when automated action is required.

Open Amazon CloudWatch →
Amazon Simple Storage Service image Amazon S3

Amazon S3 can store captured inference inputs and outputs, evaluation reports, and versioned model artifacts. Correlated production and shadow records support offline comparisons and joins with delayed ground-truth labels, subject to appropriate encryption, access, and retention controls.

Open Amazon S3 →
AWS Step Functions image AWS Step Functions

Step Functions can orchestrate shadow deployment, observation periods, evaluation jobs, and conditional promotion or cleanup through AWS service integrations. Implement explicit failure paths and rollback actions rather than treating workflow completion as proof of model quality.

Open AWS Step Functions →
AWS CodePipeline image AWS CodePipeline

CodePipeline can coordinate source, build, test, approval, and deployment stages for model-serving releases. A pipeline can invoke a shadow-evaluation workflow and require its quality gates to pass before starting a user-facing rollout.

Open AWS CodePipeline →