How it works
The explanation, with examples you can run.
Rolling updates
Instances are replaced a few at a time: start a new one, wait until it is ready, stop an old one, repeat. Kubernetes Deployments do this by default (maxSurge, maxUnavailable). It needs no extra capacity beyond the surge and no special routing. The catch is that for the length of the rollout, old and new versions serve traffic together. Every change must work in that mixed state, and a bad version is gradually reaching everyone unless something stops the rollout.
Blue-green
Run the current version (blue) and the new version (green) as two complete environments. Test green privately, then switch the router or load balancer so all traffic goes to green. If something breaks, switch back: rollback takes seconds. The costs are double capacity during the switch, and shared state. There is usually one database, so schema changes must work with both colours (see the migrations topic).
Canary
Route a small share of real traffic, say 1% then 5% then 25%, to the new version, and compare it with the old version serving the rest. Compare like with like: the canary against a baseline of the same size started at the same time, on the metrics users feel (error rate, latency, saturation). Tools like Argo Rollouts and Flagger, service meshes and cloud load balancers can do the traffic split and the analysis.
This toy analysis compares each step's canary error rate with the baseline and stops at the first bad step:
Press Run to see what your code prints, in order.
Runs in this browser, in an isolated frame with no access to this page. console.log, info, warn and error are shown; code runs as a classic script, so use an async function for await.
Real analysis also needs enough traffic for the difference to mean something; a canary that served 40 requests proves very little.
Rollback that doesn't need a meeting
Decide before the deploy what "bad" means, and wire it to an automatic action: pause the rollout, shift traffic back, or redeploy the previous digest. Keep the previous version's artifact and configuration ready. And remember that rolling back code doesn't roll back data. If the new version wrote data the old one can't read, rollback fails, which is why database changes are split into backward-compatible steps.
Check yourself
3 questions. Get them all right to finish this topic.
0 of 3 right so far. Get all three to finish this topic.