Soru

Zorluk: ZorDeployment Strategy Design

An enterprise is planning to deploy a new version of a critical monolithic web application running on Amazon EC2 instances in an Auto Scaling group (ASG) behind an Application Load Balancer (ALB). The infrastructure is managed using AWS CloudFormation. The deployment process must meet the following requirements:
- Shift exactly 10%10\% of production traffic to the new version initially.
- Route the remaining 90%90\% of traffic to the new version only after a 15-minute evaluation period.
- Perform an immediate and automatic rollback to the previous version with zero downtime if the HTTP 5xx error rate on the new version exceeds 1%1\% during the evaluation period.
- Ensure no configuration changes are made to the existing EC2 instances during the deployment, keeping the update fully immutable.

Which deployment strategy should a Solutions Architect design to meet these requirements with the least operational complexity?

  1. Provision a new Auto Scaling group running the new application version using AWS CloudFormation. Configure the Application Load Balancer with two target groups: one pointing to the existing Auto Scaling group and one pointing to the new Auto Scaling group. Use an AWS Lambda function triggered by AWS CodePipeline to update the ALB listener rule weights, routing 10%10\% of traffic to the new target group. Monitor the new target group with an Amazon CloudWatch alarm, and configure CodePipeline to revert the weights to 100%100\% on the existing target group if the alarm triggers.Cevap
  2. B
    Configure AWS CodeDeploy to perform a Blue/Green deployment using the existing Auto Scaling group as the primary environment and a newly provisioned Auto Scaling group as the replacement environment. Create a custom deployment configuration in CodeDeploy using a canary traffic-shifting policy set to route 10%10\% of traffic to the replacement environment for 15 minutes. Associate an Amazon CloudWatch alarm with the deployment group to trigger an automatic rollback if HTTP 5xx errors exceed the threshold.
  3. C
    Update the AWS CloudFormation template to modify the Amazon Machine Image (AMI) of the existing Auto Scaling group. Configure the CloudFormation update policy to use an AutoScalingRollingUpdate policy, setting MaxBatchSize to 10%10\% and MinInstancesInService to 90%90\%. Set the PauseTime to 15 minutes, and configure an Amazon CloudWatch alarm on the ALB 5xx metrics to roll back the CloudFormation stack if errors occur.
  4. D
    Use AWS CodeDeploy to perform an In-place deployment on the existing Auto Scaling group using the CodeDeployDefault.OneAtATime configuration. Configure the deployment group to use the Application Load Balancer to route traffic, and configure an Amazon CloudWatch alarm for ALB 5xx errors to trigger an automatic rollback. Implement a 15-minute block in the AppSpec file's AfterInstall hook to evaluate the performance of the first updated instance before proceeding.

Cevap

Provision a new Auto Scaling group running the new application version using AWS CloudFormation. Configure the Application Load Balancer with two target groups: one pointing to the existing Auto Scaling group and one pointing to the new Auto Scaling group. Use an AWS Lambda function triggered by AWS CodePipeline to update the ALB listener rule weights, routing 10%10\% of traffic to the new target group. Monitor the new target group with an Amazon CloudWatch alarm, and configure CodePipeline to revert the weights to 100%100\% on the existing target group if the alarm triggers.
The correct strategy involves provisioning a new Auto Scaling group (ensuring immutability) and using Application Load Balancer weighted target groups to perform canary traffic shifting. Since AWS CodeDeploy does not support canary or linear deployments for EC2 workloads, updating listener rule weights via a Lambda function in AWS CodePipeline is the standard, highly resilient method to route exactly 10%10\% of traffic. If errors exceed the threshold, reverting the listener weights back to the old target group provides an instantaneous, zero-downtime rollback.

Adım Adım Çözüm

1
Analyze the service requirements and constraints.
The application runs on EC2 instances inside an Auto Scaling group behind an Application Load Balancer. The update must be immutable (no changes to existing instances), meaning a new Auto Scaling group must be provisioned (Blue/Green).
This rules out in-place deployments.
2
Evaluate the traffic shifting requirements.
The requirement is to shift exactly 10%10\% of traffic to the new version for 15 minutes, with an immediate, zero-downtime rollback if errors occur.
Since CodeDeploy Blue/Green for EC2 only supports all-at-once traffic routing, native CodeDeploy configurations cannot satisfy the 10%10\% canary requirement. An alternative routing mechanism must be used.
3
Select the correct ALB-level routing strategy.
By using ALB weighted target groups (one for the existing ASG and one for the new ASG), traffic can be split precisely (e.g., 90%90\% to the old version, 10%10\% to the new version). AWS Lambda can automate the modification of these weights in a deployment pipeline, and a CloudWatch alarm can trigger an automatic rollback by reverting the weights back to 100%100\% on the old target group.
This achieves immutable, zero-downtime canary deployment and rollback with EC2 workloads.

Anahtar Kavram

Designing Blue/Green and Canary deployment strategies for EC2 workloads using Application Load Balancer weighted target groups when native CodeDeploy traffic shifting is unavailable.
Bu soruyu puanla