Canary evaluation
Quick answer
A canary release exposes a limited, explicitly assigned portion of traffic to a candidate while a concurrent control serves the champion. Compare quality and operational guardrails at a planned checkpoint. A passing checkpoint means eligibility for further review, not automatic full rollout. Examples use dependency-free Python with small synthetic inputs. ByteMind execution is unverified.
Stable allocation
import hashlibdef arm(key): return "candidate" if int.from_bytes(hashlib.sha256(("demo:"+key).encode()).digest()[:8],"big")%100<20 else "control"print(arm("device-1")==arm("device-1"))print(sum(arm(str(i))=="candidate" for i in range(1000)))Expected output (locally tested): True 192. The same identifier maps to the same arm for the fixed salt; realized allocation need not be exactly 20%.
How it works
Assign stable units such as anonymous user or device IDs using a reproducible salted hash and a specified allocation threshold. Choose the randomization unit to avoid contamination across repeated requests. Log assigned version and actual version separately, especially for fallback and timeout. Compare concurrent groups under the same eligibility and maturity rules; report counts, effect estimates and uncertainty. Example gate: minimum 20 mature outcomes per arm, candidate accuracy no more than five percentage points below control, error rate at most 5%, and P95 latency at most 20 ms. Predefine the duration and stop conditions; repeated peeking can inflate false positives. Real experiments need power analysis, interference checks, privacy review and approved stopping rules. Operational safety may justify early stop independent of statistical significance. Small samples that fail readiness are a HOLD, not a PASS.
Minimum sample and multiple gates
for n,acc,errors,p95 in [(10,95,0,10),(30,95,8,10),(30,95,2,18)]: print(n>=20 and acc>=85 and errors<=5 and p95<=20)Expected output (locally tested): False False True. Quality alone cannot pass the sample-size and service gates.
Common mistakes
Do not compare a low-traffic candidate with historical peak traffic without matching context. Avoid treating all requests from one device as independent, ignoring assignment imbalance, or excluding failed requests from reliability.
Practice and next steps
Calculate error rates for two arms with different denominators and decide whether a minimum-sample gate blocks a release despite a favorable observed accuracy.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Canary evaluation — knowledge check
Apply canary evaluation to small examples and debugging scenarios.
What is a canary?
Why use stable assignment by device?
What if sample size is below the planned minimum?
What if latency violates a release gate?
What can repeated unplanned significance checks do?