Deployment Strategies: Rolling, Blue Green, Canary and Linear

Topics Covered

The Vocabulary of Deployment Strategies

The questions every strategy answers

All at once and in place

Rolling and rolling with an additional batch

Immutable

Blue green

Canary and linear

A comparison you can recall under pressure

Mixed versions are a design constraint

What the exam is really checking

Worked example: reading a stem for properties

Strategies are not only for code

Every deployment replaces running code with new code, and the strategy decides how that replacement happens: all at once or in pieces, on the same machines or on new ones, with traffic switched in one move or shifted gradually. The Deployment domain asks you to pick a strategy from a short list of requirements, such as no downtime, no reduced capacity, fastest rollback or lowest cost, and then to know how each AWS service implements it. This lesson covers the strategies and their AWS implementations in Elastic Beanstalk, Lambda, API Gateway, EC2 and ECS. The mechanics of CodeDeploy's appspec files and lifecycle hooks are in the CI/CD lesson, and the CloudFormation, SAM and Beanstalk basics are in the infrastructure as code lesson; here you build on both.

The questions every strategy answers

Before memorising names, learn the five properties that distinguish strategies, because exam stems are written in terms of these properties rather than names.

Downtime: is there a moment when no instance can serve requests? Capacity: during the deployment, does the fleet run with fewer instances than usual, the same number, or more? Mixed versions: do old and new code serve users at the same time, and for how long? Rollback: if the new version is bad, how quickly can you return to the old one, and does that require another deployment? Cost: do you pay for extra resources during the deployment?

A stem that says the application must keep serving at full capacity during deployments rules out plain rolling. A stem that says the fastest possible rollback points towards blue green or immutable. A stem that says cost must be minimal and some downtime is acceptable, as in a development environment, points to all at once. Practise reading stems for these five properties first.

All at once and in place

All at once deploys the new version to every instance simultaneously. It is the fastest strategy and costs nothing extra, but every instance restarts at the same time, so there is a brief outage, and if the new version is broken, the whole application is broken until you deploy the old version again. In place means the deployment reuses the existing instances rather than creating new ones. All at once is always in place. It suits development and test environments, and it is the default in several services, which is a reason exam questions about production sometimes hinge on changing it.

Rolling and rolling with an additional batch

A rolling deployment updates a batch of instances at a time. The batch leaves the load balancer, gets the new version, passes health checks and returns, then the next batch goes. There is no downtime as long as the batch is smaller than the fleet, but capacity drops by one batch during the deployment, and users are served by both versions until the last batch finishes. Rollback means another rolling deployment of the old version, which takes as long as the original.

A rolling deployment updates a few instances at a time, so capacity dips but never hits zero.

Rolling with an additional batch first launches one extra batch of new instances, so the fleet never drops below full capacity. Then it rolls through the existing instances as normal and finally terminates the extra batch. It costs a little more during the deployment and is the answer when a stem asks for rolling behaviour without reduced capacity.

Immutable

An immutable deployment never modifies existing instances. It launches a full set of new instances running the new version, waits for them to pass health checks, moves them into service and only then terminates the old instances. If any new instance fails, the new instances are terminated and the old fleet is untouched, so rollback is fast and clean. During the deployment, you briefly run double capacity, which costs more. Because nothing is changed in place, there is no risk of a half updated instance left in a strange state, a common cause of hard to debug failures with in place strategies.

Blue green

Blue green runs two complete environments. Blue is the current production; green is a new environment with the new version. You test green in isolation, then switch all production traffic from blue to green in one move, usually by changing DNS, a load balancer listener or a Lambda alias. If something goes wrong, you switch back, which is as fast as the switch itself because blue is still running. After a while, you tear down blue or keep it as the next green. The cost is running two environments at once, and the extra complexity is in state: both environments usually share one database, so the new version must work with the existing schema.

Canary and linear

Canary and linear are traffic shifting strategies. Instead of moving all users at once, they move a percentage. A canary moves a small slice first, such as ten percent, waits for a set period while monitoring, then moves the rest in one step. Linear moves traffic in equal increments at equal intervals, such as ten percent every minute until all traffic has moved. Both rely on monitoring during the shift, usually CloudWatch alarms that trigger automatic rollback, so a bad version only hurts the users in the first slice.

Canary and linear are variants of blue green in the sense that two versions run side by side and traffic moves between them, but with gradual movement instead of one switch. On AWS they are most closely associated with Lambda aliases, API Gateway stages and ECS services, where traffic can be split precisely by weight.

A comparison you can recall under pressure

Here is a compact way to hold the trade offs. All at once: fast, cheap, downtime, slow rollback. Rolling: no downtime, reduced capacity, mixed versions, slow rollback. Rolling with additional batch: no downtime, full capacity, mixed versions, slightly more cost. Immutable: no downtime, full capacity, double capacity briefly, fast rollback, slowest to deploy. Blue green: no downtime, instant switch and switch back, runs two environments. Canary: small blast radius, then a big step. Linear: gradual and predictable, takes longest to complete.

text
1strategy           downtime  capacity during   rollback speed   extra cost
2all at once        yes       zero briefly      redeploy         none
3rolling            no        reduced           redeploy         none
4rolling + batch    no        full              redeploy         small
5immutable          no        full (double)     fast             high, briefly
6blue green         no        full (two envs)   instant switch   high
7canary / linear    no        full              instant shift    depends on platform

Mixed versions are a design constraint

Whenever two versions serve users at the same time, which is true for rolling, canary and linear, and briefly for blue green when DNS caches are involved, both versions must be compatible with each other's data. If version two writes a new field to a DynamoDB item that version one cannot parse, a user bouncing between instances will see errors. If version two drops a database column that version one still reads, version one instances fail during the rollout. The fix is to design changes in compatible steps, which section five covers. Exam questions sometimes describe errors only during deployments, and mixed version incompatibility is the cause.

What the exam is really checking

Most strategy questions are trade off questions in disguise. The stem gives two or three constraints, such as no downtime, no capacity reduction, and minimal cost, and only one strategy satisfies all of them. A good method is to cross out options that violate a hard constraint first, then pick the cheapest or simplest of what remains. Watch for wording: zero downtime is not the same as full capacity, and quickest rollback is not the same as fastest deployment. The next sections map each strategy onto specific AWS settings, because the exam's options usually name the setting rather than the strategy.

Worked example: reading a stem for properties

Consider a stem: an e-commerce team deploys a web application to an EC2 fleet behind a load balancer, peak traffic needs every instance, releases happen during the day, and finance wants no large temporary bills. Read for the five properties. Downtime is not acceptable, so all at once is out. Capacity must stay full, so plain rolling is out. Large temporary cost is unwelcome, so blue green with a full second fleet and immutable with double capacity are weaker. Rolling with an additional batch remains: full capacity, no downtime, one batch of extra cost. Now change one requirement: the team says a failed release last month left a mixed fleet for an hour, and that must never happen again. That sentence is about failure behaviour, and it moves the answer to immutable even though it costs more.

Strategies are not only for code

The same vocabulary applies to anything you roll out: configuration, infrastructure and even database parameters. A CloudFormation stack update that replaces an Auto Scaling group can use a rolling update policy or a replacing update policy, the latter being an immutable replacement of the whole group. AppConfig deploys configuration with linear or canary style strategies and a bake time. Recognising the pattern under a different service name is a fast way through unfamiliar options, because the trade offs stay the same.

Read the stem for five properties

Before looking at options, note what the stem says about downtime, capacity during deployment, mixed versions, rollback speed and cost. Usually one or two of these rule out all but one strategy.