Copyright (c) 2026 MindMesh Academy. All rights reserved. This content is proprietary and may not be reproduced or distributed without permission.

4.1.7. Deployment Strategies: Blue/Green, Rolling, and Canary

šŸ’” First Principle: Every deployment is a controlled risk. The question is not whether something might go wrong, but how quickly you can detect it, how many users it affects when it does, and how fast you can revert. Deployment strategies are risk management tools — you trade deployment complexity and speed for blast radius reduction and rollback capability.

The Four Primary Strategies:
StrategyHow It WorksDowntimeRollback SpeedRisk
In-place (All-at-once)Replace all running instances simultaneouslyāœ… PossibleāŒ Slow (redeploy old version)Highest
RollingReplace instances in batches (e.g., 25% at a time)āŒ Noneāš ļø MediumMedium
Blue/GreenNew environment alongside old; switch traffic when readyāŒ Noneāœ… Instant (switch back)Low
CanaryRoute small % of traffic to new version; expand if healthyāŒ Noneāœ… FastLowest
Blue/Green Deployment on AWS:

The "blue" environment runs the current version. The "green" environment runs the new version. Traffic switches from blue to green all at once (via DNS, load balancer, or Auto Scaling group swap).

Implementation options:

  • Route 53 weighted routing: Shift 0% → 100% between two ALBs
  • ALB target group swap: Two target groups; update listener rules
  • Auto Scaling group swap: CodeDeploy manages two ASGs
Canary/Traffic Splitting:

Route a small percentage of real traffic to the new version, monitor for errors, then gradually increase:

AWS CodeDeploy Deployment Types:
Compute PlatformDeployment Types Available
EC2/On-premisesIn-place, blue/green
LambdaCanary, linear, all-at-once
ECSBlue/green (via ALB target group swap)

Immutable Deployments: Instead of updating existing instances, launch an entirely new set of instances with the new version. Only swap traffic when the new fleet is healthy. Existing instances are terminated after the swap. This is the safest EC2 deployment pattern — old instances are never modified.

AppSpec File: CodeDeploy uses an appspec.yml file to define deployment hooks — scripts that run at specific lifecycle events:

Lifecycle EventRuns When
BeforeInstallBefore the new application version is installed
AfterInstallAfter installation, before starting
ApplicationStartTo start the application
ValidateServiceTo verify the deployment succeeded

āš ļø Exam Trap: "Blue/green" for ECS with CodeDeploy works by creating a new task set (green) alongside the existing one (blue), then shifting traffic at the ALB level. It is not implemented by running two separate ECS clusters — both task sets run in the same cluster. The ALB has two target groups (blue and green), and CodeDeploy manages the traffic shift percentage.

Reflection Question: Your team deploys a critical payment service update. Requirements: no downtime, instant rollback capability if errors spike, and real production traffic should validate the new version before full rollout. Which deployment strategy do you use, and how does it enable each requirement?

Alvin Varughese
Written byAlvin Varughese
Founder•15 professional certifications