Module 12 · Project 12 · Ship with Zero Downtime · Lesson 40 of 48

Rolling, blue-green and canary

Three ways to replace a running version without users noticing, what each costs, and how each behaves when the new version is broken.

In this lesson · about 35 minutes

  • Explain rolling updates, blue-green and canary releases
  • Compare their cost, rollback speed and blast radius
  • Describe automated canary analysis

Why "deploy at 2 am" isn't the answer

Stopping the old version and starting the new one means downtime, however short. Doing it at night just moves the pain to the on-call engineer, and global users are awake anyway. Zero-downtime deployments keep enough healthy copies serving traffic the whole time. They also make releases boring, which means you can do them often, in daylight.

Rolling update

Replace Pods a few at a time. Kubernetes Deployments do this by default:

spec:
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1          # at most 1 extra Pod during the rollout
      maxUnavailable: 0    # never fewer ready Pods than replicas

Cheap (one extra Pod) and built in. But for a while both versions serve traffic, and if v2 is subtly broken, more and more users hit it until someone notices. Rollback is another rolling update.

Blue-green

Run two full environments. Blue serves users; deploy v2 to green, test it privately, then switch all traffic at once (load balancer, DNS or Service selector). Rollback is flipping back, in seconds. The cost: double capacity during the release, and when the switch happens, everyone gets v2 at once.

Canary

Send a small slice of real traffic (say 5%) to v2, compare it with v1, and only widen it (25%, 50%, 100%) while it looks healthy. A bad release hurts a few users briefly, not everyone. Tools such as Argo Rollouts or Flagger automate it, using your Prometheus metrics (Project 09) for analysis:

strategy:
  canary:
    steps:
      - setWeight: 5
      - pause: { duration: 10m }
      - analysis: { templates: [{ templateName: error-rate }] }   # abort if worse than stable
      - setWeight: 25
      - pause: { duration: 10m }
      - setWeight: 50
      - pause: { duration: 10m }

Canaries need traffic splitting (a service mesh, an ingress controller that supports weights, or weighted target groups on an AWS load balancer) and good metrics, or the analysis has nothing to judge.

Try it · watch it run

Rolling, blue-green and canary releases

Play each strategy with a healthy v2. Then turn on the bug and play them again. Watch the share of failing requests and how fast each one gets back to safety.

notes-api Deployment (maxSurge 1, maxUnavailable 0) LIVE

v1v1v1v1
traffic to v1 · 100%v2 · 0%

Requests failing now

0.0%

Worst so far

0.0%

Extra capacity

+1 Pod (maxSurge)

Rollback

Another rolling update (minutes)

Step 1 of 10Four v1 Pods serve all traffic. You change the image tag to v2.

Whiteboard · watch and try

Blast radius in numbers

Press Play. The tutor works out how many requests a bad release breaks.

5 steps
Press Play and the tutor will talk you through it while writing on the board. Pause any time to write on the board yourself.

Tip: press Pause, then use the pen to work along on the board. Space plays and pauses; Ctrl+Z undoes your last mark.

Sorting drill

Which strategy fits?

Pick the best strategy for each situation.

  • Small internal tool, tight budget, Kubernetes default is fine
  • Must be able to roll back in seconds, and capacity is affordable
  • Millions of users; a bad release must only reach a few
  • A release that must switch everyone at the same moment (a coordinated API change)
  • You have good metrics and want to test with real traffic first

0 of 5 sorted

Check your understanding0 of 3 correct

Question 1

1.What does maxUnavailable: 0 guarantee in a rolling update?

Question 2

2.What's blue-green's biggest strength?

Question 3

3.What does a canary analysis step compare?

Key terms

Say the meaning to yourself, then tap a card to check.

Quiz score: 0 of 3

Tip: answer every quiz question correctly first.

Written by Noviq Academy in its own words. The labs are simulations: no real servers are touched. When you build the projects yourself, use a practice virtual machine or a free-tier cloud account you control, watch your cloud spending, and never run cleanup or delete commands on a machine you care about. Tool names belong to their owners; versions and output are shown for learning and may differ slightly from yours. Read-aloud and the whiteboard voice use your device's built-in voices.