Soru

Zorluk: ZorDeployment Strategy Design

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 10%10\% of live traffic is routed to the new version for 1515 minutes to monitor performance.
* Automated rollback within 33 minutes if the Application Load Balancer's 5XX5\text{XX} 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?

  1. A
    Configure 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.
  2. B
    Configure 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.
  3. C
    Use 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.
  4. 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.Cevap

Cevap

Create a new (green) Auto Scaling group targeting a new Application Load Balancer target group, provision it with 10%10\% capacity, and use AWS CodePipeline with AWS Lambda to adjust Application Load Balancer routing weights to 10%10\% and 90%90\% respectively. Monitor using CloudWatch alarms, and immediately revert the weight to 0%0\% 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., 10%10\%). It satisfies the cost constraint because the green Auto Scaling group is initially provisioned with only 10%10\% of the capacity rather than a duplicate fleet. If an alarm is triggered during the 1515-minute monitoring window, rollback is rapid (less than 11 minute) by changing the ALB routing weight for the green target group to 0%0\%. 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.

Adım Adım Çözüm

1
Create a separate green Auto Scaling group and target group representing 10%10\% of the blue Auto Scaling group's capacity.
A green target group containing new instance versions is created with minimal additional cost, satisfying the constraint of not doubling the fleet size.
Bypasses the default CodeDeploy EC2 blue/green requirement of launching a duplicate fleet of equivalent size.
2
Use AWS CodePipeline to invoke an AWS Lambda function to update the Application Load Balancer routing weights to 10%10\% for the green target group and 90%90\% for the blue target group.
Traffic is split at the load balancer level, sending exactly 10%10\% of live traffic to the new version.
Enables canary testing for EC2 instances, which is not natively supported with canary routing configurations in AWS CodeDeploy.
3
Monitor the green target group metrics using CloudWatch alarms for 1515 minutes. If alarms trigger, invoke the Lambda function to set the green target group routing weight back to 0%0\%.
Immediate redirection of all traffic back to the healthy blue environment within seconds.
Achieves the rollback target of less than 33 minutes without waiting for instance replacement or redeployment.
4
If the evaluation period passes successfully, scale up the green Auto Scaling group to full production capacity, shift the routing weight to 100%100\% green, and scale down the blue group to zero.
Promotion of the new version to full production and termination of old instances.
Completes the deployment lifecycle while maintaining zero downtime.

Anahtar Kavram

Canary Deployments on EC2 using Application Load Balancer Weighted Target Groups
Bu soruyu puanla