A/B Testing Models with Production Variants
This lesson explains how A/B testing with production variants serves different models to different users and measures effects on behaviour and business outcomes that offline metrics cannot show.
Learning outcomes
After completing this lesson, you will be able to:
- Configure production variants and traffic weights.
- Measure and adjust variant traffic.
- Design a trustworthy test.
- Compare A/B testing with shadow tests and other methods.
Production variants
A SageMaker AI endpoint configuration can contain several production variants, each with its own model, instance type and count, and a traffic weight. SageMaker AI splits requests by weight, such as 90% to the current model and 10% to the challenger. A caller can bypass the split with the TargetVariant parameter, for example to keep a user on the same variant or to test one variant directly. The response header reports which variant served the request.
Split the traffic
Measuring and adjusting
CloudWatch publishes invocation, latency and error metrics per variant. Business outcomes, such as clicks or purchases, are logged by the application with the variant name and analysed with Athena or Quick Sight. Run the test long enough to reach statistical significance. Weights are changed with UpdateEndpointWeightsAndCapacities without redeploying, so the winner can be ramped up gradually and the loser removed.
The following diagram shows the variants, their weights and how the outcome is measured in an A/B test of a recommendation model.

Designing a trustworthy test
An A/B test is an experiment, and its conclusions are only as good as its design. The success metric, such as conversion rate or average order value, must be chosen before the test starts, together with the smallest improvement worth detecting. These two values determine the sample size each variant needs: detecting a 1% relative improvement in a conversion rate of 3% requires far more users than detecting a 10% improvement. A small challenger weight, such as 10%, protects users but means the test must run longer to collect enough data.
The unit of randomisation should usually be the user, not the request. If each request is routed independently, one user sees both models, which mixes their effects and makes outcomes such as repeat purchases impossible to attribute. The application can assign each user to a variant once, store the assignment and send it with TargetVariant on later requests.
Common mistakes invalidate results. Stopping as soon as one variant looks better inflates false positives, because random fluctuations often favour one side early. Changing weights, models or the metric during the test mixes different experiments. Running the test over too short a period, such as two days that miss weekend behaviour, measures an unrepresentative sample. A sound test runs for whole business cycles, checks that both variants are healthy operationally, and applies a significance test only once the planned sample size is reached.
A test you can trust
A/B testing compared with other methods
The following table compares the live comparison methods.
| Method | Users see new model | Measures | Mechanism |
|---|---|---|---|
| Shadow test | No | Latency, errors, prediction agreement | Shadow variant |
| A/B test | Yes, a share | Business outcomes | Production variants with weights |
| Canary deployment | Yes, briefly | Operational health during rollout | Deployment guardrails |
A canary deployment is a release mechanism that checks operational health, while an A/B test is an experiment that compares outcomes.
Testing a recommender
A team wants to know whether a new recommendation model increases purchases, without exposing most users to it.
ProductionVariants:
- VariantName: current ModelName: recs-v8 InitialVariantWeight: 9
- VariantName: challenger ModelName: recs-v9 InitialVariantWeight: 1
# After two weeks: challenger conversion +3.1% (significant), latency equal
aws sagemaker update-endpoint-weights-and-capacities --endpoint-name recs \
--desired-weights-and-capacities VariantName=current,DesiredWeight=1 VariantName=challenger,DesiredWeight=9The application logs the served variant with each purchase, which is what makes the conversion comparison possible. A shadow test could not have measured purchases, because users never saw the challenger's recommendations.
How can a request be sent to a specific variant?
Show answer
With the TargetVariant parameter.
Exam Tips
Remember for the exam
- Compare business outcomes on real users: A/B test with production variants.
- Traffic weights split requests; TargetVariant forces a variant.
- Change weights without redeploying: UpdateEndpointWeightsAndCapacities.
- Log the served variant with business events.
- Run until results are statistically significant.