Adding Health Checks to Your Auto Scaling Group
By default, an Auto Scaling group determines the health state of each instance by periodically checking the results of the EC2 instance status checks. If an instance fails the EC2 instance status checks, Auto Scaling considers the instance unhealthy and replaces it. However, if you have attached one or more load balancers to your Auto Scaling group and an instance fails the load balancer health checks, Auto Scaling does not replace the instance by default.
You can configure your Auto Scaling group to use both EC2 instance status checks and load balancer health checks to determine the health status of your instances. If you enable load balancer health checks and an instance fails the health checks, Auto Scaling considers the instance unhealthy and replaces it. If you attach multiple load balancers to an Auto Scaling group, all the load balancers must report that the instance passed the health checks in order for Auto Scaling to consider the instance healthy. If one load balancer reports an instance as unhealthy, Auto Scaling replaces the instance, even if the other load balancers report it as healthy. For more information, see Health Checks for Auto Scaling Instances.
If connection draining is enabled for your load balancer, Auto Scaling waits for the in-flight requests to complete or for the maximum timeout to expire, whichever comes first, before terminating instances due to a scaling event or health check replacement. For more information, see Connection Draining in the Classic Load Balancer Guide.
Adding Health Checks Using the Console
Use the following procedure to add an
ELB health check with a grace period of
300 seconds to an Auto Scaling group with an attached load balancer.
To add health checks using the console
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
On the navigation pane, under Auto Scaling, choose Auto Scaling Groups.
Select your group.
On the Details tab, choose Edit.
For Health Check Type, select
For Health Check Grace Period, enter
On the Instances tab, the Health Status column displays the results of the newly added health checks.
Adding Health Checks Using the AWS CLI
Use the following update-auto-scaling-group command to create a health check with a grace period of 300 seconds:
aws autoscaling update-auto-scaling-group --auto-scaling-group-name
my-lb-asg--health-check-type ELB --health-check-grace-period