QA Interview Hub · Knowledge base · Quizzes · Українська

Product Engineering › Safe releases and production feedback

Canary, gradual rollout, blue-green, rollback

A safe release limits the blast radius: a canary gives the new version to a small share of traffic, and a gradual rollout widens it in steps. Blue-green keeps two copies of production and switches traffic. Stop criteria, including business metrics, are agreed before the release. Rollback fits an unknown cause, fix-forward only a known cause when rolling back is risky. Migrations follow the expand/contract pattern.

Product Engineering · Safe releases

A release to everyone at once broke payments on Android. How do you make 2% of people suffer instead of all?

On Friday at 16:00 a new version was released to all traffic. By 16:20 complaints reached support: payment on Android returns an error. The rollback took an hour because the cause was investigated first. During that time everybody suffered. If only 2% of users had received the version, the failure would have been noticed in the metrics within minutes, and hundreds of people would have been affected, not tens of thousands. This lesson is about the techniques that limit the blast radius and about the "rollback or fix-forward" decision.

How it works and why. The main idea of safe releases is to limit the blast radius. Instead of "everyone at once" the new version is shown to a small part of the traffic, signals are watched, and only then it is widened. Pre-release testing cannot reproduce everything: real data, devices and load exist only in production. So part of the risk is moved to a controlled stage after the deploy, where a mistake is still cheap.

  • Canary. The new version runs next to the old one and receives a small percentage of traffic (1–5%). If the metrics are normal, the percentage grows; if not, the canary is switched off and only a small share of users suffers. The name comes from the canary in a coal mine;
  • Gradual rollout (staged / percentage). The same at the level of a feature or app: 1% → 10% → 50% → 100% with pauses for observation. App stores have staged release (the App Store phased release follows a fixed schedule, Google Play staged rollout uses a percentage you choose);
  • Blue-green. Two full copies of production: "blue" serves traffic, the new version is deployed and checked in "green". Then the traffic is switched over entirely. Rollback means switching back. The downside: double resources, and a shared database requires compatible migrations;
  • Dark launch. The feature is already deployed in production but not shown to users. Often it is fed real traffic invisibly to people: for example, requests are duplicated to a new service and the responses are compared without returning them. The aim differs from a flag that gradually opens a feature, although a flag can be a tool here too.

Gradual rollout with a check at every stage

1% of trafficthe first signal check10% of trafficmetrics normal? go on50% of trafficload and rare cases100% of trafficthe old path is still ready for rollback
Figure 1. Signals permit every move, not the calendar. A stop at a threshold happens automatically or by a clear rule.

Example: a rollout plan with entry criteria. The condition for all this is criteria set before the start: which metrics and which threshold values count as a signal to stop the rollout. These decisions are made before the release, not under the pressure of an incident:

Stage 1:  1% of traffic, 30 min -> watch the signals
Stage 2: 10% of traffic, 1 h
Stage 3: 50% of traffic, 2 h
Stage 4: 100%

Stop and roll back if, within the watch window:
  - the 5xx share is above 1% (normal 0.2%)
  - p95 response time is above 800 ms (normal 500 ms)
  - successful payments are below 90% of the usual for this hour
  - crashes exceed 0.5% of sessions
The thresholds here are illustrative: set them for your product.

Two principles are at work here. First, the thresholds are written before the release, so the decision to stop does not depend on an argument in the chat at 16:20. Second, the comparison is with the norm for this hour and day of the week, not with an abstract number, because on Friday evening behaviour differs from Tuesday morning. A small percentage has a price too: on 1% of traffic rare errors are barely visible, so a stage must last long enough and the metrics must have a sample from which something can be said.

Rollback or fix-forward? Rollback means returning the previous version: fast and predictable when the impact is serious and the cause is not obvious. Fix-forward means quickly releasing a fix: appropriate when the cause is known, the fix is small and rollback is risky (for example, a data migration already applied that is incompatible with the old code).

Two legitimate answers to an incident

Rollback

Return the previous version

When the impact is serious, the cause is unknown and the previous version is compatible with the current data. Fast and predictable.

Fix-forward

Quickly release a fix

When the cause is known and the fix is small, while rollback is risky because of data changes already applied.

Figure 2. The choice depends on the situation. The default rule: when unsure, roll back.

That is why migrations are made compatible, in three steps: expand / contract. First add the new, then switch over, and only later remove the old:

-- 1. expand: added a new column, the old code works unchanged
ALTER TABLE orders ADD COLUMN currency_code text;

-- 2. migrate: backfilled, the new code writes to both columns
UPDATE orders SET currency_code = currency WHERE currency_code IS NULL;

-- 3. contract: in a separate release, when the old code is gone
ALTER TABLE orders DROP COLUMN currency;

While steps 1-2 are in place, both versions of the code work and rollback is safe. Step 3 is done in a separate release, when the old code is nowhere left: after it the old version cannot be brought back. That is why "drop the column" and "ship the new version" must not be one release.

Limits and alternatives. A gradual rollout does not help if there are no metrics or they are not visible: without signals 1% only postpones the problem. It is weak for rare failures on small samples and for changes that cannot be shown to part of the people (a schema change, a shared cache). Blue-green is expensive and does not solve data incompatibility. In mobile apps an installed version cannot be rolled back, so flags and a kill switch that can be turned off without an update matter more there. And for small teams without infrastructure a canary can be replaced by a simple one: release first to internal users, then to a percentage behind a flag.

Common mistakes.

  • Releasing "to everyone at once" with no stop threshold.
  • Agreeing the stop criteria during the incident.
  • Comparing metrics with an abstract number, not with the norm for this hour and day of the week.
  • Merging a migration that drops the old with the new code in one release: rollback becomes impossible.
  • Considering blue-green safe when both environments share a database with an incompatible schema.
  • Looking only at technical signals and missing a drop in business metrics.

Check yourself

An hour after a 100% release a payment bug was noticed. A migration that dropped the old column has already run. Why may rollback not help and what now?

Answer

The old code version expects a column that no longer exists, so after the rollback it will break. If the fix is small and the cause is known, do a fix-forward. A lesson for the future: removing the old is a separate later step (expand/contract), when rollback is no longer needed.

A canary gets 2% of traffic, 5xx is normal, and payment conversion has dropped. Can the rollout be widened?

Answer

No. A release can produce no errors and still break the value, for example when a button is not displayed. Business metrics must be among the stop criteria next to the technical ones. The rollout is stopped and the cause is investigated.

In an interview. Junior: A safe release limits the blast radius: a canary gives the new version to a small percentage of traffic, a gradual rollout widens it in steps, blue-green keeps two copies and switches traffic. If the metrics worsen, we roll back. Middle/Senior: We agree the stop criteria and thresholds before the release and take them from business metrics, not only technical ones. I choose rollback or fix-forward by the situation: rollback when unsure, fix-forward when the cause is known and rollback is risky. I make migrations by expand/contract so that rollback stays safe, and remember the limit: mobile apps have no rollback, so a kill switch is needed.

More articles in this chapter