Video in progress

How does a canary release work, and why is it so often used together with metrics?

The new version first gets a small share of traffic (say 5%), you watch errors and latency, and if everything is fine the share is raised step by step. A canary without metrics is just a slow deploy.

📖 Answer

The idea: if there is a problem, it should hit a minority of users, not all of them.

The simplest way is the replica ratio: 19 old pods and 1 new pod behind one Service, which is roughly 5% of traffic. If you need a more exact percentage, you use an Ingress/Gateway (for example, NGINX canary annotations, weight in the Gateway API) or a service mesh.

What the decision is based on:

  • whether the share of 5xx errors on the canary is worse than on the old version;
  • p95/p99 latency;
  • business metrics: payment success rate, number of orders.
5% -> watch 15 min -> 25% -> 50% -> 100%
         \-- errors went up -> 0% (rollback)

Argo Rollouts or Flagger automate this process: based on a Prometheus query, they move to the next step or roll back on their own.

One subtle point: at low traffic the canary does not collect enough statistics. At night, 5% of 100 requests an hour is 5 requests, and you cannot conclude anything from them. So choose the observation time based on traffic volume.