4
votes

I'm trying to put my autoscaling groups behind an application load balancer (not a classic ELB) and was wondering if it is possible for my autoscaling group to use an application load balancer to health check its instances.

I want instances the application load balancer deems unhealthy to automatically be terminated and for the autoscaling group to create a new one.

What i've found currently happens is my target group marks instances as unhealthy but I am unable to get the autoscaling group to use the ALBs health checks, is this possible?.

Attempting to edit load balancers field on autoscaling group: enter image description here

2

2 Answers

10
votes

Yes, you can.

When a Load Balancer detects an unhealthy instance, it simply stops sending traffic to the instance. It does not terminate the instance.

When Auto Scaling detects an unhealthy instance, it terminates the instance and automatically replaces it to maintain the Desired Capacity. However, the default health checks performed by Auto Scaling only look at the underlying health of the virtual machine -- it is not able to check the health of applications.

Fortunately, you can combine health checks between Load Balancing and Auto Scaling. This way, if the Load Balancer detects an unhealthy application, Auto Scaling can terminate and replace the instance.

Be careful! If the health checks are incorrectly configured, it may cause thrashing (continually adding and removing instances). For example, if an insufficient warmup period has been specified, Auto Scaling might terminate an instance before it is fully ready.

See documentation Health Checks for Auto Scaling Instances:

If you have attached a load balancer to your Auto Scaling group, you can optionally have Auto Scaling include the results of Elastic Load Balancing health checks when determining the health status of an instance.

Auto Scaling health check

Note:

  • When using a Classic Load Balancer, Auto Scaling uses the health check from the Load Balancer
  • When using an Application Load Balancer, Auto Scaling uses the health check from the Target Group

The Application Load Balancer will not appear in the "Load Balancer" list within the Auto Scaling group configuration. Instead, select the appropriate Target Group.

5
votes

I have been able to recreate my problem by creating an autoscaling group but not attaching the target group at creation time.

Instead, after the autoscaling group had a running instance I editted its settings to attach a target group to the autoscaling group. When I did this the instance would not correctly register as unhealthy in the autoscaling group.