Sub topic 7
Canary Release: Exposing a Small Share of Users in Stages
Assume you can serve a model behind an HTTP or RPC endpoint, read latency and error metrics, and use basic proportions and averages. A canary release is a rollout method that sends a small, controlled share of real user requests to a candidate model while most requests continue using the stable model.
Offline evaluation can show that the candidate performs well on stored data. A canary tests whether it behaves safely with current traffic, dependencies, and users. The candidate produces user-visible results, so a canary has more risk than a shadow deployment. However, the limited exposure reduces the size of a failure.
Route a small percentage of traffic
A traffic router chooses the model version before the request reaches the model server. For example, an Istio VirtualService can send 95% of requests to the stable subset and 5% to the candidate subset.
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
name: fraud-model
spec:
hosts:
- fraud-model
http:
- route:
- destination:
host: fraud-model
subset: stable
weight: 95
- destination:
host: fraud-model
subset: candidate
weight: 5The matching DestinationRule must define the stable and candidate subsets. The weights describe traffic allocation, not model quality. A 5% canary does not mean the candidate is expected to be 5% better.
A typical rollout increases exposure only after the current stage passes its checks.
Measure safety before promotion
Define the promotion rule before sending traffic. Compare the candidate with the stable model over the same time window. Useful guardrails include:
| Category | Example metric | Example rule |
|---|---|---|
| System | p95 latency | Candidate is no more than 10% slower |
| Reliability | Error rate | Candidate increases errors by no more than 0.5 percentage points |
| Model | Invalid or low-confidence outputs | Candidate stays below a fixed limit |
| Business | Chargeback or conversion rate | Candidate does not harm the agreed outcome |
A guardrail should have a threshold, an observation window, and an action. For example, “roll back if the candidate error rate exceeds the stable rate by 0.5 percentage points for five minutes” is actionable. “Watch errors closely” is not.
Use enough traffic and time for the metrics to mean something. A five-minute window may detect crashes, but it may not reveal a rare fraud error or a delayed customer outcome. Automatic rollback should be conservative, fast, and reversible.
Keep exposure controlled
If users can make repeated requests, use sticky assignment. Sticky assignment means the same user or account keeps receiving the same model during the experiment. Without it, one user may see inconsistent behavior, and comparisons become harder to interpret.
For a high-risk model, start with shadow deployment, then use a small canary, and finally run a carefully designed A/B test for business impact. A canary answers, “Is this candidate safe enough to expose gradually?” It does not by itself prove that the candidate improves the long-term business metric.
Exercise
A candidate has equal error rate but 18% higher p95 latency than stable. Should a 10% canary advance if the latency guardrail allows only a 10% increase?
Show answer
No. The candidate fails the latency guardrail, so keep the current stage or roll back according to the predefined policy.