Sub topic 8
Deciding to Promote or Roll Back
Assume you can serve two model versions behind an HTTP or RPC endpoint, route requests between them, and read metrics such as error rate, latency, and business conversion. This chapter uses basic proportions and averages.
A rollout decision should be based on predefined evidence, not on a quick look at a dashboard. Promotion means sending more or all traffic to the candidate model. Rollback means returning traffic to the stable model because the candidate is unsafe, too slow, or not useful enough.
Separate promotion criteria from guardrails
Promotion criteria answer: “Is the candidate good enough to receive more traffic?”
Guardrails answer: “Has the candidate caused unacceptable harm?”
Use both kinds of criteria:
- Model quality: accuracy, precision, recall, calibration, or ranking quality when labels are available.
- System behavior: error rate, timeout rate, CPU use, memory use, and p95 latency.
- Business behavior: conversion, revenue, fraud loss, complaint rate, or other relevant outcomes.
- Safety and fairness: policy violations, bad outputs, or unacceptable differences between user groups.
A promotion rule might require the candidate to improve the primary metric while staying within limits for every guardrail. A rollback rule should usually be stricter and faster. For example, a small latency increase might block promotion, while a sharp error-rate increase triggers immediate rollback.
| Metric | Stable | Candidate | Rule |
|---|---|---|---|
| Error rate | 0.20% | 0.30% | Increase must be at most 0.05 percentage points |
| p95 latency | 120 ms | 128 ms | Candidate must be at most 10% slower |
| Conversion rate | 4.8% | 5.4% | Candidate should improve the primary metric |
Percentages and percentage points are different. An increase from 0.20% to 0.30% is 0.10 percentage points, or a 50% relative increase.
Use gates that can be evaluated automatically
A gate is a programmatic check that returns whether the rollout can advance. Compare the candidate with the stable version over the same period and, when possible, the same traffic population.
def canary_gate(stable: dict, candidate: dict,
max_error_increase: float = 0.0005,
max_latency_ratio: float = 1.10) -> bool:
error_ok = candidate["error_rate"] <= (
stable["error_rate"] + max_error_increase
)
latency_ok = candidate["p95_latency_ms"] <= (
stable["p95_latency_ms"] * max_latency_ratio
)
return error_ok and latency_ok
stable = {"error_rate": 0.002, "p95_latency_ms": 120}
candidate = {"error_rate": 0.003, "p95_latency_ms": 128}
print(canary_gate(stable, candidate)) # FalseThe example blocks promotion because the error rate increased by 0.10 percentage points. A real gate should also check minimum request counts, data freshness, missing metrics, and segment-level failures. Missing data must not be treated as a passing result.
Promote in stages and preserve a fast rollback
A staged rollout might move from 1% to 5%, 25%, 50%, and 100%. Pause long enough at each stage to collect enough requests and observe important traffic periods. At every stage:
- Check that telemetry is complete.
- Compare candidate and stable metrics.
- Check critical user segments, not only aggregate results.
- Advance only when all gates pass.
- Roll back immediately when a hard guardrail fails.
Keep the stable version available until the candidate has passed its observation window. A rollback should change routing, not delete the candidate. Record the trigger, traffic level, timestamps, and model versions so the incident can be investigated.
Exercise
The stable model has a 0.20% error rate and 120 ms p95 latency. The candidate has a 0.25% error rate and 135 ms p95 latency. With a maximum error increase of 0.05 percentage points and a maximum latency ratio of 1.10, should the rollout advance?
Show answer
No. The error-rate limit is met exactly, but 135 ms is greater than 132 ms, which is 110% of 120 ms. Hold or roll back according to the rollout policy.