Video in progress

What system do you build to analyze a canary release automatically and roll it back on its own if needed?

I compare the canary and baseline pods' metrics over the same time window: error rate, p99 latency, saturation and a business metric. Argo Rollouts or Flagger manage the steps, and if a threshold is crossed, they send traffic back automatically.

📖 Answer

The most common mistake is comparing the canary against the "old prod". The old pods have been warm for a week, and the new canary came up 2 minutes ago. The right way: new baseline pods (the old version) are brought up at the same time as the canary, and those are compared.

An example with Argo Rollouts:

strategy:
  canary:
    steps:
      - setWeight: 5
      - pause: { duration: 10m }
      - analysis:
          templates: [{ templateName: error-rate }]
      - setWeight: 25
      - pause: { duration: 15m }
      - setWeight: 100

An AnalysisTemplate queries Prometheus, for example the share of 5xx by the version label. If the threshold is crossed, the rollout goes Degraded and traffic returns to the old version.

Choosing metrics:

  • the share of 5xx and timeouts is the main one;
  • p99 latency, not the average;
  • a business signal, such as the share of successful payments. Some errors return 200 but give a wrong result;
  • JVM-specific: GC pauses and heap growth, since memory leaks may not show up in 10 minutes.

The statistics problem: at 5% traffic, if 10 minutes gives 300 requests, a single error looks like 0.3%. For low-traffic services, stretch the window or require a minimum request count, otherwise noise causes random rollbacks and the team stops trusting the analysis.

Automatic rollback is safe only for code. If a release makes a migration or an irreversible write to an external system, hide it behind a flag first.