A company is designing a deployment process for a critical production web application that runs on Amazon EC2 instances within an Auto Scaling group behind an Application Load Balancer. The deployment must satisfy the following constraints:
* Zero downtime during updates.
* A canary phase where of live traffic is routed to the new version for minutes to monitor performance.
* Automated rollback within minutes if the Application Load Balancer's error rate or instance CPU utilization exceeds defined thresholds.
* Cost constraints prevent launching a complete duplicate fleet of instances during the traffic-shifting phase.
Which deployment strategy should the solutions architect recommend to meet these requirements?
- AConfigure AWS CodeDeploy to perform a blue/green deployment using the CodeDeployDefault.ECSCanary10Percent15Minutes configuration. Configure CloudWatch alarms on the Application Load Balancer 5XX metrics and instance CPU utilization, and configure CodeDeploy to automatically roll back if these alarms are triggered.
- BConfigure AWS CodeDeploy to perform an in-place deployment with a custom deployment configuration that updates 10% of the instances first, pauses the deployment for 15 minutes for validation, and then updates the remaining 90%. Configure CloudWatch alarms to trigger a deployment rollback if any threshold is exceeded.
- CUse AWS CloudFormation to update the Auto Scaling group using an AutoScalingRollingUpdate policy. Set the MinInstancesInService parameter to maintain 90% capacity and set the MaxBatchSize to 10%. Configure a CloudWatch alarm for Application Load Balancer 5XX errors to trigger a stack rollback if needed.
- Create a new (green) Auto Scaling group targeting a new Application Load Balancer target group, and provision it with 10% of the capacity of the existing (blue) Auto Scaling group. Use AWS CodePipeline to invoke an AWS Lambda function that sets the Application Load Balancer routing weights to 10% for the green target group and 90% for the blue target group. Monitor the green target group via CloudWatch alarms for 15 minutes. If an alarm triggers, set the green target group weight to 0% immediately. Otherwise, scale up the green group, shift the routing weight to 100%, and scale down the blue group to zero.Answer
Answer
Create a new (green) Auto Scaling group targeting a new Application Load Balancer target group, provision it with capacity, and use AWS CodePipeline with AWS Lambda to adjust Application Load Balancer routing weights to and respectively. Monitor using CloudWatch alarms, and immediately revert the weight to on alarm triggers.
Using two separate Auto Scaling groups (blue and green) with Application Load Balancer (ALB) weighted target groups allows for a true canary deployment of EC2 instances with fractional traffic routing (e.g., ). It satisfies the cost constraint because the green Auto Scaling group is initially provisioned with only of the capacity rather than a duplicate fleet. If an alarm is triggered during the -minute monitoring window, rollback is rapid (less than minute) by changing the ALB routing weight for the green target group to . Since CodeDeploy does not support canary or linear traffic shifting for EC2/on-premises deployments (these configurations are only supported for AWS Lambda and Amazon ECS), a custom orchestration approach using ALB weighted target groups and AWS Lambda is the correct and most optimal solution.
Step-by-Step Solution
Key Concept
Canary Deployments on EC2 using Application Load Balancer Weighted Target Groups