Adding Elastic Load Balancing health checks to an Auto Scaling group
The default health checks for an Auto Scaling group are EC2 status checks only. If an instance fails these status checks, it is marked unhealthy and will be terminated while Amazon EC2 Auto Scaling launches a new instance in replacement.
You can attach one or more load balancer target groups, one or more Classic Load Balancers, or both to your Auto Scaling group. However, by default, the Auto Scaling group does not consider an instance unhealthy and replace it if it fails the health checks provided by Elastic Load Balancing.
To ensure that your Auto Scaling group can determine an instance's health based on
additional
tests provided by the load balancer, you can configure the Auto Scaling group to use
Elastic Load Balancing
(ELB
) health checks. The load balancer periodically sends pings,
attempts connections, or sends requests to test the EC2 instances and determines if
an
instance is unhealthy. If you configure the Auto Scaling group to use ELB
health
checks, it considers the instance unhealthy if it fails either the EC2 status checks
or
the ELB
health checks. If you attach multiple load balancer target groups
or Classic Load Balancers to the group, all of them must report that the instance
is
healthy in order for it to consider the instance healthy. If any one of them reports
an
instance as unhealthy, the Auto Scaling group replaces the instance, even if other
ones report
it as healthy.
See the following topics:
-
To configure health checks for your Application Load Balancer, see Health checks for your target groups in the User Guide for Application Load Balancers.
-
To configure health checks for your Network Load Balancer, see Health checks for your target groups in the User Guide for Network Load Balancers.
-
To configure health checks for your Gateway Load Balancer, see Health checks for your target groups in the User Guide for Gateway Load Balancers.
-
To configure health checks for your Classic Load Balancer, see Configure health checks for your Classic Load Balancer in the User Guide for Classic Load Balancers.
-
For more information about Amazon EC2 Auto Scaling health checks, see Health checks for Auto Scaling instances.
The following procedures show how to add ELB
health checks to your Auto Scaling
group.
Adding health checks (console)
Use the following procedure to add an ELB
health check to an Auto Scaling
group with an attached load balancer.
To add health checks
-
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/
. -
On the navigation pane, under AUTO SCALING, choose Auto Scaling Groups.
-
Select the check box next to an existing group.
A split pane opens up in the bottom part of the Auto Scaling groups page, showing information about the group that's selected.
-
On the Details tab, choose Health checks, Edit.
-
For Health check type, select Enable ELB health checks.
-
For Health check grace period, enter the amount of time, in seconds, that Amazon EC2 Auto Scaling needs to wait before checking the health status of an instance. Frequently, new instances need to briefly warm up before they can pass a health check. To provide ample warm-up time, set the health check grace period of the group to match the expected startup time of your application.
-
Choose Update.
-
On the Instance management tab, under Instances, you can view the health status of instances. The Health Status column displays the results of the newly added health checks.
Adding health checks (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-period300