Home > database >  When does AWS deregister an EC2 from the auto-scaling group during scale-in?
When does AWS deregister an EC2 from the auto-scaling group during scale-in?

Time:01-14

I am trying to figure out when and how AWS deregisters an EC2 from an auto-scaling group during scale-in. I am especially worried about a case when an EC2 which is about to be terminated will receive an incoming request shortly before being terminated. This would naturally cause processing of the requst to fail. The desired behavior would be for AWS to deregister the about-to-be-terminated instance from the group some configurable time before actually terminating it. I have found no documentation about this specific issue. Am I missing something?

CodePudding user response:

There's no configuration that guarantees that a specific time elapses between deregistering an instance from the group and terminating it.

You can use Elastic Load Balancer health checks to remove instances that are not responding from the load balancer endpoint before they are terminated.

CodePudding user response:

From AWS Documentation https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-termination-policies.html

Default termination policy The default termination policy applies multiple termination criteria before selecting an instance to terminate. When Amazon EC2 Auto Scaling terminates instances, it first determines which Availability Zones have the most instances, and it finds at least one instance that is not protected from scale in. Within the selected Availability Zone, the following default termination policy behaviour applies:

Determine whether any of the instances eligible for termination use the oldest launch template or launch configuration:

[For Auto Scaling groups that use a launch template]

Determine whether any of the instances use the oldest launch template, unless there are instances that use a launch configuration. Amazon EC2 Auto Scaling terminates instances that use a launch configuration before it terminates instances that use a launch template.

[For Auto Scaling groups that use a launch configuration]

Determine whether any of the instances use the oldest launch configuration.

After applying the preceding criteria, if there are multiple unprotected instances to terminate, determine which instances are closest to the next billing hour. If there are multiple unprotected instances closest to the next billing hour, terminate one of these instances at random.

  • Related