Sub topic 8
Canary Analysis: Deciding to Promote or Abort
This chapter assumes you know what a canary deployment is, can read basic service metrics such as error rate and latency, and have seen a Kubernetes Ingress. Here you will learn how to decide, with evidence, whether a canary should receive all traffic or be pulled back.
What canary analysis is
Canary analysis compares the new version (the canary) with the current version (the baseline) while both serve real traffic. The outcome is one of three decisions:
- Promote: send more traffic to the canary, until it takes 100%.
- Hold: keep the current weight and collect more data.
- Abort: set the canary weight to zero and investigate.
Sending traffic to a canary is only the first step. Without a decision rule, the canary just runs a new version for an unknown time.
Set the rules before you start
Decide the criteria before the canary starts. If you pick them after seeing the numbers, you will tend to explain away bad results.
A usable plan has four parts:
- Signals. The metrics you will compare, such as error rate, p99 latency, and saturation (CPU, memory, queue depth).
- Thresholds. The limit for each signal, for example "canary 5xx rate is no more than 0.2 percentage points above baseline".
- Steps. The traffic weights you will move through, for example 5%, 25%, 50%, 100%.
- Soak time. How long the canary stays at each step before you decide.
Compare the canary with the baseline running at the same time, not with last week's numbers. Traffic changes by hour and by day, so a live baseline removes that noise.
Starting the canary
The canary Ingress sends about 10% of requests for web.example.com to the web-canary Service. The primary Ingress for the same host keeps the rest.
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: web-canary
annotations:
nginx.ingress.kubernetes.io/canary: "true"
nginx.ingress.kubernetes.io/canary-weight: "10"
spec:
ingressClassName: nginx
rules:
- host: web.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: web-canary
port:
number: 80To promote, raise canary-weight step by step. To abort, set it to "0" or delete this Ingress. Real tools such as Argo Rollouts or Flagger automate these steps, but they apply the same logic.
Reading the results
The main difficulty is that a small canary produces little data. At 10% of 100 requests per second, the canary handles about 10 requests per second. One error in a short window can look like a 10% error rate.
Keep these points in mind:
- Check sample size. Do not judge a signal until the canary has served enough requests for the metric to be stable. For a rare event, wait longer.
- Use percentiles, not averages. An average can hide a slow tail. Compare p95 or p99 latency.
- Look at business signals too. Checkout success rate or login rate can drop while HTTP errors stay flat.
- Watch for slow failures. Memory leaks and connection pool exhaustion appear only after some time. A short soak time misses them.
- Allow for noise. Two identical versions will still differ a little. Set thresholds above that normal gap.
The decision loop
Two rules keep this loop safe:
- Abort on a clear breach without waiting. A threshold breach is a reason to stop immediately, not a reason to gather more data.
- Promote only on healthy data. Missing data is not a pass. If metrics are absent because the canary's metric labels are wrong, treat that as a failure.
Common mistakes
| Mistake | Effect | Fix |
|---|---|---|
| Judging after one minute | Misses slow failures | Set a minimum soak time per step |
| Comparing with the whole fleet | Canary problems are diluted | Filter metrics by canary and baseline |
| Thresholds chosen after the fact | Bad results get rationalized | Write thresholds into the rollout plan |
| Treating no data as success | A broken canary is promoted | Fail the step when metrics are missing |
| Sticky sessions or caching skew traffic | The canary sees an unrepresentative sample | Check that the canary receives a typical request mix |
Exercise
A canary at 5% weight shows the same overall 5xx rate as before. The canary pods alone show 4% 5xx, while baseline pods show 0.1%. Should you promote? Give two reasons for your answer.
Show answer
No, abort (or at least hold and investigate). First, the canary's own error rate is far above the baseline's, which breaches any reasonable threshold. Second, the overall rate looks unchanged only because the canary's 5% share dilutes its errors, so comparing against the whole fleet hid the problem.
Exercise
Your canary metrics dashboard shows no data for the canary pods during a step. What should the analysis decide, and why?
Show answer
It should fail or hold the step, not promote. Missing data is not evidence of health. The canary could be crashing, not receiving traffic, or not exporting metrics, and promoting would be a blind release.