Model A/B testing is a controlled online experiment in which live requests or users are randomly split between a current production model and one or more candidate models, so that their effect on real outcome metrics can be compared with statistical rigor. In MLOps & deployment, it is the final validation step between offline evaluation and full rollout, also described as an online model experiment.
Offline metrics such as accuracy or AUC show how a model scores on historical data, but they often fail to predict user behavior, revenue or latency in production. A/B testing closes that gap by measuring the causal effect of a model change on the people and systems it actually serves.
How model A/B testing splits and measures traffic
A model A/B test works by assigning each randomization unit, usually a user, session or account, to a variant through a deterministic hash of its identifier. The control group keeps the incumbent model (A), while the treatment group receives the candidate model (B). Stable assignment matters: if one user sees both models, the effects contaminate each other and the comparison loses validity.
The serving layer, often a feature-flag service or a router inside the inference platform, logs every prediction together with the variant label and a request identifier. Downstream events such as clicks, purchases or support tickets are later joined to those logs, which allows analysts to compute metrics per variant and test whether the observed difference exceeds random variation.
The table below lists the main components of a typical setup and the role each one plays.
| Component | Role | Typical failure if missing |
|---|---|---|
| Assignment service | Hashes units into stable variants | Users flip between models |
| Model router | Sends requests to model A or B | Uneven or leaking traffic |
| Exposure logging | Records variant, request and prediction | Metrics cannot be attributed |
| Metrics pipeline | Joins outcomes to exposures | Delayed or biased results |
| Statistical engine | Computes effects and confidence intervals | Decisions based on noise |
Metrics and statistical parameters
Every test needs one primary metric chosen before launch, a set of guardrail metrics that must not degrade, and a pre-registered analysis plan. The primary metric should reflect the business goal, for example conversion rate or watch time, rather than a proxy that the new model was trained to optimize directly.
Sample size follows from four inputs: the baseline rate, the minimum detectable effect, the significance level and the desired statistical power. Common defaults are a significance level of 0.05 and power of 0.8, although teams that run many tests often tighten thresholds to limit false discoveries.
| Parameter | Typical value | Effect of a stricter setting |
|---|---|---|
| Significance level (alpha) | 0.05 or 0.01 | Fewer false positives, larger sample |
| Statistical power | 0.8 to 0.9 | Fewer missed effects, longer test |
| Minimum detectable effect | 0.5% to 5% relative | Smaller effect needs much more traffic |
| Traffic allocation | 50/50 or 90/10 | Unequal split reduces power |
| Test duration | 1 to 4 full weeks | Captures weekly seasonality |
Variance reduction techniques such as CUPED, which adjusts outcomes using pre-experiment covariates, can shorten tests considerably. Sequential testing methods allow safe early stopping, whereas repeatedly checking a fixed-horizon test, known as peeking, inflates the false positive rate.
How it compares with related release strategies
Model A/B testing is one of several progressive delivery patterns, and each answers a different question. Shadow deployment checks technical behavior without affecting users, a canary release limits blast radius, and a champion-challenger model setup compares candidates over a longer period, often in regulated domains.
| Pattern | Users affected | Main question answered |
|---|---|---|
| Model A/B testing | Random share sees model B | Does B cause better outcomes |
| Shadow deployment | None, B runs silently | Is B stable, fast and consistent |
| Canary release | Small share, increased gradually | Is B safe to roll out |
| Champion-challenger | Defined share over months | Does B beat A over time |
| Multi-armed bandit | Shifting share toward winners | Which variant earns most during the test |
A multi-armed bandit reduces the cost of exposing users to a weaker model, but it gives less reliable effect estimates than a fixed randomized split. Teams that need a defensible decision record usually prefer a classic A/B test.
Running a model A/B test in practice
A sound workflow starts with offline evaluation and shadow traffic, so that only candidates that are technically healthy reach users. The team then writes a hypothesis, fixes the primary metric and duration, runs an A/A test or sample ratio check to validate the plumbing, and launches with a small allocation before ramping to the planned split.
- Validate the candidate offline and in shadow mode.
- Define the hypothesis, primary metric and guardrails.
- Calculate sample size and duration in advance.
- Launch, monitor guardrails daily and check the sample ratio.
- Analyze once at the planned end and record the decision.
- Promote, iterate or perform a model rollback.
The decision table below maps common results to a recommended action.
| Result | Recommended action | Reason |
|---|---|---|
| Primary metric up, guardrails stable | Promote model B | Clear net benefit |
| Primary metric flat, latency better | Promote with caution | Operational gain only |
| Primary metric up, guardrail down | Investigate before promoting | Hidden harm possible |
| Sample ratio mismatch detected | Discard and rerun | Assignment is broken |
| No significant difference | Keep model A or extend test | Effect smaller than planned |
Limitations and common mistakes
Model experiments carry pitfalls that general product tests rarely face. Feedback loops arise when a model influences the data used to train its successor, and delayed ground truth, for example loan defaults that appear months later, can make short tests misleading. Network effects in marketplaces or social products violate the assumption that units are independent.
- Peeking at results and stopping early when the difference looks significant.
- Novelty effects that fade after the first days of exposure.
- Optimizing a short-term proxy that harms long-term retention.
- Ignoring training-serving skew that makes model B behave differently in production.
- Running many overlapping tests without correcting for multiple comparisons.
Ethical and regulatory constraints also apply. In credit, health or hiring, exposing a random group to an unvalidated model may require review and documentation, and fairness metrics should be monitored per segment, not only in aggregate.
Stripped to the essentials
Imagine a shop that wants to test a new way of suggesting products. It does not switch everyone at once. Instead, it shows the old suggestions to half of the visitors and the new ones to the other half. Visitors are picked by chance, so both groups are alike.
After a few weeks, the shop compares the two groups. Did people buy more? Did the site get slower? If the new version clearly wins and causes no harm, it replaces the old one. That is model A/B testing: a fair, side-by-side contest with real people, judged by real results.
Where it is applied
A video streaming service trains a new recommendation model that improves offline ranking accuracy by 3% on held-out data. Before replacing the production model, the team routes 10% of users to the candidate for two days to check latency and error rates, then ramps to a 50/50 split for three weeks.
The primary metric is weekly viewing hours per user, and guardrails include playback start time and subscription cancellations. At the planned end, the candidate shows a 1.2% increase in viewing hours with a confidence interval that excludes zero, while guardrails stay flat. The team promotes the new model, records the result in the model registry and keeps the old version ready for an immediate rollback.