Production ML
Advanced 15 min read Production ML

Online Testing: Shadow, Canary & A/B

Prove it against real traffic before you trust it

Offline evaluation can't see distribution shift. Shadow deployments run a candidate on real traffic without deciding, canaries flip a small slice, and A/B tests measure business impact with statistical rigor. Each is a real-traffic interrogation with its own risk profile.

shadow deploycanaryA/B testtraffic splitinference-time evaluationpowerdirected acyclic
Before we start

What you will learn

  • Compare shadow, canary and A/B evaluation on real traffic
  • Design traffic-split experiments with power and runtime
  • Choose the technique from the risk and the question you're asking
Introduction

What is this?

Online testing lets real traffic interrogate a candidate model. Shadowing runs the candidate alongside production and logs its decisions without affecting users — pure observation, zero user risk. Canary gradually shifts a small, monitored slice of traffic (5%→100%) to catch issues early with rollback. A/B testing randomly assigns users to two models and measures business metrics (conversion, revenue) to decide with statistics whether the change wins. Offline metrics predict; online tests prove.

Motivation

Why do you need it?

  • Curated offline data can't represent live distributions; only real traffic can.
  • Business impact (revenue, retention) is rarely the metric you optimized offline — A/B measures the thing your model exists for.
  • Each technique trades risk for signal: shadow is safe but indirect; canary risks a slice; A/B measures causal impact.
  • Incremental rigor beats 'it looked better in the notebook' for every promotion decision.
Think about it

Mental model

Imagine

Flight testing: wind tunnel, first flight, certification

Think of

Offline, shadow/canary, A/B

A wind tunnel (offline eval) predicts a lot but can't test real turbulence and pilots. A first flight with a chase plane (shadow) gathers real data safely. A small fleet rollout (canary) finds what the chase plane missed. Full certification with routes and passengers (A/B at scale) validates the economics. No team skips the ladder and still calls the plane ready.

Mechanics

How it works

  • Shadow: duplicate traffic to a candidate, log its scores, serve the incumbent's decision; diff candidate vs incumbent distributions.
  • Canary: route X% of live requests to the candidate; compare latency/errors/proxies; promote or roll back on thresholds.
  • A/B: stable random assignment of users/models; run long enough for power; measure the primary business metric plus guardrail metrics.
  • Loop variant: A/B is also good for decision-threshold experiments without touching the model weights.
  • Gate every promotion on a pre-registered decision rule so analysts choose before results load.

Escalating-risk online testing ladder.

Offline eval
Shadow
Canary
A/B
Full rollout
Real world

In production

  • A recommender shadows candidate v2 for a week, abandons it when score distributions diverge too far, and only then canaries 5%.
  • A search team A/B tests a reranker on 10% of users, gated on CTR and p95 latency as the guardrail.
  • A pricing model canaries by region, rolling back instantly when revenue-per-request dips on the flagged cohort.
Guidelines

Best practices

  • Go shadow → canary → A/B in order of evidence need and risk appetite; never skip straight to 100%.
  • Pre-register the decision rule: effect size, metric, power and run length before the experiment starts.
  • Keep guardrail metrics (latency, error rate, other business KPIs) monitored during every rollout phase.
  • Automate canary promotion/rollback thresholds so humans review, not babysit.
  • Log consistency between shadow and live so you can audit 'would the candidate have changed this decision'.
Watch out

Common mistakes

  • Running one A/B, piecing it, and promoting without power — then attributing the next week's noise to the model.
  • Using A/B for a recommendation change whose unit isn't independently assignable (network effects break the assumption).
  • Canary rolling so fast there's no window to detect latency regressions before 100%.
  • Shadowing without storing decisions — missing the whole evidential value.
Root cause analysis

Common issues

Error
Canary latency regression disappears before rollback
Root cause

Caching/warm-up asymmetry masking the real cold performance

Fix

Force cold-start measurement (bypass cache initially) and keep a baseline canary pool warm.

Error
A/B declares a false win
Root cause

Multiple testing (peeking) or low power

Fix

Pre-register the analysis, use sequential/peek-corrected testing and a firm sample-size budget.

Error
Shadow candidate matches production perfectly
Root cause

Shadow path reuses production weights/features and never exercises the candidate

Fix

Verify the shadow serves the candidate's artifact and its own feature path.

When things break

Debugging tips

  • Diverge-score distributions between shadow and live; a candidate that never changes decisions is dead weight or a bug.
  • Watch guardrail latency during the first canary hours; cold-start caching differences show up there.
  • For A/B, verify assignment balance (no Simpson-style confounds) before reading results.
  • If an A/B shows a win but the shadow diff looked calm, check whether the change touches decision thresholds, not weights.
Interviews

Interview checkpoint

Practice

Hands-on lab

Shadow Diff, Canary Slicing & Power Primer
30 min · advanced
In progress
Objectives
  • Simulate shadow mode: log candidate scores while serving the incumbent's decisions
  • Compute a divergence metric between candidate and incumbent score distributions
  • Compute the sample size needed for a real A/B with given effect and power

Shadow Diff, Canary Slicing & Power Primer

30 min · advanced

0/5 steps
0%
sandbox · Linux sandbox
$
Try these commands
Test yourself

Quick quiz

0/2
1

Which technique evaluates a candidate with zero user-facing impact?

2

A/B tests measure business impact but need statistical power and pre-registered rules to be trustworthy.

Go deeper

Official documentation