Soru

Zorluk: OrtaAuto Scaling and Elasticity

A SysOps administrator is troubleshooting an issue where an Amazon EC2 Auto Scaling group behind an Application Load Balancer (ALB) is registering new instances with the ALB before they are fully configured, leading to temporary HTTP 502 Bad Gateway errors. The administrator implements an `EC2_INSTANCE_LAUNCHING` lifecycle hook to pause the instance state during initialization. Arrange the sequence of operational steps and state transitions that must occur for a new instance to be successfully configured and start receiving healthy traffic from the ALB.

  1. 1Auto Scaling launches a new EC2 instance in response to a scale-out alarm.
  2. 2The instance begins booting and enters the Pending state.
  3. 3The EC2_INSTANCE_LAUNCHING lifecycle hook triggers, transitioning the instance to the Pending:Wait state.
  4. 4The instance runs its User Data script to complete software installation and configuration.
  5. 5A script on the instance calls the complete-lifecycle-action API with the CONTINUE result.
  6. 6Auto Scaling registers the instance with the ALB target group, transitioning the instance to InService after health checks pass.

Cevap

The correct order of steps starts with Auto Scaling launching the instance, transitioning it to the Pending state, pausing it via the launch lifecycle hook (Pending:Wait), executing the bootstrap scripts, completing the lifecycle action with a CONTINUE signal, and finally registering the instance with the Application Load Balancer target group to transition to the InService state.
The correct sequence ensures that the instance remains in a paused state (Pending:Wait) while configuration scripts run, preventing the load balancer from routing traffic to an unconfigured instance. The lifecycle hook must be completed using the API before Auto Scaling proceeds with load balancer registration and transitioning the instance to the InService state.

Adım Adım Çözüm

1
Auto Scaling responds to a scale-out alarm.
A new EC2 instance is launched.
To scale out capacity as defined by the scaling policy.
2
The instance boots up.
State transitions to Pending.
This is the default initial state for launching Auto Scaling instances.
3
The configured EC2_INSTANCE_LAUNCHING lifecycle hook triggers.
State transitions to Pending:Wait.
To pause the launch process and prevent early registration with the ALB.
4
The instance executes the bootstrap scripts specified in its User Data.
Software dependencies are installed and the application starts.
To configure the instance for production traffic while paused.
5
The configuration script invokes the complete-lifecycle-action CLI command.
State transitions to Pending:Proceed.
To signal to Auto Scaling that bootstrapping is complete.
6
Auto Scaling registers the instance with the ALB target group and monitors target health.
State transitions to InService once health checks pass.
To allow healthy traffic to be routed to the newly configured instance.

Anahtar Kavram

Auto Scaling Lifecycle Hooks and State Transitions
Tahmini Süre:2m 0s
Bu soruyu puanla