# Release Strategies

Course: [CI/CD](https://www.devtutorials.ai/learn/cicd) · Section: Continuous Delivery
Source: https://www.devtutorials.ai/learn/cicd/continuous-delivery/release-strategies

> Release to a fleet of 10 servers four ways: all at once, rolling, blue-green and canary. Measure the blast radius of a bad release and pick the right strategy.

## Release Strategies

Your app runs on 10 servers. A new version is ready.

How do you move users to it?

- **All at once:** fast, but a bad release hits everyone.
- **Rolling:** a few servers at a time.
- **Blue-green:** a full new copy, then one switch.
- **Canary:** a small slice of users first.

**Simple lesson:** the release strategy decides how many users a bad release can hurt.

### A Real-World Example

Think about a new canteen menu.

- **All at once:** every student gets the new dish on Monday. If it is bad, the whole school is unhappy.
- **Rolling:** one class a day tries it.
- **Blue-green:** a second kitchen cooks the new menu. At lunch, you switch which counter is open.
- **Canary:** ten students taste it first. If they like it, everyone gets it.

**Simple lesson:** try it on a few, watch, then go wider.

## Blast Radius

**Blast radius** = how many users a bad release can reach before it is stopped.

- Small blast radius = small damage.
- Every strategy below is a way to shrink it.
- Each lab measures it for you.

- All 10 servers switch together.
- Users see a short outage while servers restart.
- With a bad version, 100% of users get it.

**Simple lesson:** all at once is simple, but the blast radius is everyone.

## Rolling

**Rolling release** = update a few servers at a time, checking health after each batch.

- **Batch size** = how many servers change at once.
- A health check runs after each batch.
- If errors go up, the rollout stops and rolls back.

- Smaller batch = smaller blast radius, but a slower release.
- During the rollout, old and new versions run side by side.

**Simple lesson:** small batches plus a health check keep the damage small.

## Blue-Green

**Blue-green** = run the new version (green) next to the old one (blue), then switch all traffic in one step.

- Users only move when green is ready.
- Undo is one switch back to blue.
- It needs double the servers for a while.

- Blue-green does not shrink the blast radius much: everyone moves at once.
- It makes the **undo** instant, with no downtime.

**Simple lesson:** blue-green trades extra servers for a one-step undo.

## Canary

**Canary** = send a small slice of users to the new version, watch it, then promote.

- Start with 10% of users.
- Watch the error rate for a while.
- Below the limit: promote to 50%, then 100%.
- Over the limit: stop and roll back.

A canary only works if something watches it. Turn the health check off in the next lab and see what happens.

**Simple lesson:** a canary is real users testing your release. Watch them closely.

## Choosing a Strategy

| Strategy | Blast radius | Undo speed | Extra cost |
|---|---|---|---|
| All at once | Everyone | Slow (redeploy) | None |
| Rolling | One batch | Medium | None |
| Blue-green | Everyone, briefly | Instant switch | Double servers for a while |
| Canary | The canary slice | Fast | Needs traffic splitting and metrics |

Real tools:

- **Azure Pipelines:** deployment jobs support `runOnce`, `rolling` and `canary` strategies.
- **Azure App Service:** deployment slots give you blue-green with a "swap".
- **GitHub Actions:** no built-in strategy. You call your cloud's tools from a step.

**Real tools vs this lab:** real canaries watch error rates, response times and business numbers for minutes or hours. In this lab, a 10-server fleet is simulated, and one release takes a few seconds.

```yaml
# Azure Pipelines: a canary on a Kubernetes environment
- deployment: release
  environment: production.shop-namespace
  strategy:
    canary:
      increments: [10, 50]
      deploy:
        steps:
          - script: echo deploying $(strategy.increment)%
```

Start with rolling releases plus a health check. Move to canary when you have good error metrics. Without metrics, a canary has nothing to watch.

**Simple lesson:** pick the strategy that fits your servers, your budget and your metrics.

## Where to Go Next: Kubernetes and GitOps

Bigger teams often run containers on **Kubernetes**, a system that manages many containers on many servers.

- Kubernetes does **rolling** updates by itself. You set how many pods change at a time.
- Tools like **Argo Rollouts** or **Flagger** add canary and blue-green, with metric checks.
- **GitOps** (Argo CD, Flux): the pipeline does not push to the cluster. It changes an image tag in a Git repo. A tool in the cluster sees the change and applies it.
- Every rule from this course still applies: build once, SHA tags, smoke tests, small blast radius, a fast way back.

You do not need Kubernetes for this course. App Service is enough for most small apps.

**Simple lesson:** the strategies are the same. Kubernetes and GitOps are just other ways to run them.

1. In the Azure portal, open your production app → **Deployment slots**. (Slots need the Standard plan or higher.)
2. Read how a slot swap works: deploy to a `staging` slot, check it, then swap.

**What you should see:** a swap is blue-green on App Service. You do not need to pay for it now. Just know where it lives.

## Quick Check

## Cheat Sheet

| Strategy | Key setting | Good for |
|---|---|---|
| All at once | none | Tiny internal tools |
| Rolling | batch size, health check | A fixed set of servers |
| Blue-green | two copies, one switch | Fast undo, no downtime |
| Canary | slice %, error limit, wait time | Large user bases with metrics |

## Common mistakes

| Mistake | Wrong idea | Correct idea | What goes wrong |
|---|---|---|---|
| Canary with no metric | Small slice = safe | Something must watch it | It slowly reaches everyone |
| Error limit too high | A loose limit avoids false alarms | Set it near normal error rates | Bad releases get promoted |
| Huge rolling batches | Faster is better | Small batches limit harm | Half the users hit at once |
| Blue-green without a smoke test | Switching back is easy | Check green before the switch | Everyone sees the bug first |
| All at once for a busy site | It is simpler | Pick a strategy with an undo | Every user hit, plus downtime |

## What to Remember

- Blast radius = how many users a bad release can hurt.
- Rolling: a few servers at a time, with a health check.
- Blue-green: one switch forward, one switch back.
- Canary: a small slice, watched, then promoted.
- Every strategy needs something watching it.

## Exercises

Next: **Rollback and Recovery**
