Sub topic 1
Why Deployment Strategy Matters: Risk, Downtime, and Releasing vs. Deploying
Prerequisites
This chapter assumes you have run a web service in production and know what a container and a load balancer do. You should recognize common service metrics such as error rate and latency. Later chapters use Kubernetes Deployments and Services in examples, so basic familiarity with them helps. This chapter needs no Kubernetes knowledge.
What a deployment strategy is
A deployment strategy is the plan for moving production from an old version of a service to a new one. The plan answers four questions:
- How many instances change at a time?
- Which users see the new version first?
- How do you know the new version works?
- How do you go back if it does not?
The simplest strategy is to stop the old version and start the new one. This is often called a recreate deployment. It is easy to run, but the service is down between the stop and the start. Every strategy in this tutorial exists to avoid that gap and to limit the damage when a new version is bad.
Where release risk comes from
Most production incidents follow a change. A new version can fail in several ways:
- It crashes on startup because of a missing setting.
- It starts but returns errors under real traffic.
- It works but is slower, so latency climbs and requests time out.
- It is correct, but it breaks a client or a database that still expects the old behavior.
Tests in staging catch many of these, but not all. Production has real data, real traffic patterns, and real dependencies. A deployment strategy accepts that some bad versions will reach production. It controls how many users are affected and for how long.
Two quantities describe the risk:
- Blast radius is the share of users or requests affected by a bad version.
- Time to recover is how long it takes to return to a good state after you notice a problem.
A good strategy lowers both. The strategies differ in how they trade these against cost and complexity.
Deploying versus releasing
These two words are often used as if they meant the same thing. They do not.
- Deploying means putting a version of the code onto production infrastructure.
- Releasing means exposing that version's behavior to users.
With a plain deployment, the two happen together. The moment new pods or servers take traffic, users are on the new version. Separating them gives you more control. You can deploy a version that receives no traffic, check it, and then release it. You can also release to 5% of users, then 50%, then everyone.
Each strategy in this tutorial separates deploying from releasing in a different way:
| Strategy | How it separates deploy from release |
|---|---|
| Rolling | Barely. Release follows deploy batch by batch. |
| Blue-green | The new version runs fully idle, then one switch releases it. |
| Canary | A small share of traffic is released first, then the share grows. |
Feature flags, covered in the last chapter, separate the two at the code level instead of the infrastructure level.
A worked comparison
Suppose a service runs on four instances and handles 1,000 requests per second. The new version has a bug that fails 20% of requests.
- Recreate: All traffic stops during the swap. Then 20% of 1,000 requests per second fail until someone rolls back.
- Rolling: The new version replaces instances one at a time. After the first batch, one of four instances is bad, so about 5% of all requests fail. If you notice, you stop the rollout there.
- Blue-green: The new environment is tested before the switch. If the bug only appears under real traffic, the switch exposes all users at once, and 20% of requests fail until you switch back. The switch back is fast.
- Canary: 10% of traffic goes to the new version. Only about 2% of all requests fail, and metrics show the problem before the share grows.
No strategy is best in every case. Blue-green needs a second full environment. Canary needs good metrics and traffic routing. Rolling is cheap but leaves old and new versions running together for a while.
What the rest of the tutorial covers
The next chapters build the pieces these strategies depend on: health checks, traffic routing, and release metrics. After that, each strategy gets its own treatment, followed by rollback, database compatibility, and a guide for choosing between them.
Exercise
A team deploys a new version and it immediately receives all production traffic. Another team deploys the same version, runs it with no user traffic, checks it, and then sends 5% of traffic to it. Which team separated deploying from releasing, and why does that reduce risk?
Show answer
The second team did. They put the version on production infrastructure (deployed) before exposing users to it (released). Their checks happen before any user is affected, and the 5% share limits the blast radius if the version is bad.