Set the health check grace period for an Auto Scaling group
When an Amazon EC2 Auto Scaling health check determines that an InService
instance is
unhealthy, it replaces it with a new instance. The health check grace period specifies
the minimum amount of time (in seconds) to keep a new instance in service before
terminating it if it's found to be unhealthy.
An example use case might be a requirement for Amazon EC2 Auto Scaling to avoid taking action if the
Elastic Load Balancing health checks fail and the cause is that the instance is still initializing. Elastic Load Balancing
health checks run in parallel, starting when the instance is registered with the load
balancer. The grace period prevents Amazon EC2 Auto Scaling from marking your newly launched instances
Unhealthy
and terminating them unnecessarily if they don't immediately
pass these health checks after they enter the InService
state.
In the console, by default, the health check grace period is 300 seconds when you create an Auto Scaling group. Its default value is 0 seconds when you create an Auto Scaling group using the AWS CLI or an SDK. A value of 0 turns off the health check grace period.
Setting this value too high reduces the effectiveness of the Amazon EC2 Auto Scaling health checks.
If you use lifecycle hooks for instance launch, you can set the health check grace
period to 0. With lifecycle hooks, Amazon EC2 Auto Scaling provides a way to make sure that instances
are always initialized before they enter the InService
state. For more
information, see Amazon EC2 Auto Scaling lifecycle hooks.
The grace period applies to the following instances:
-
Newly launched instances
-
Instances that are put back into service after being in standby
-
Instances that you manually attach to the group
Important
During the health check grace period, if Amazon EC2 Auto Scaling detects that an instance is no
longer in the Amazon EC2 running
state, it immediately marks the instance
Unhealthy
and replaces it. For example, if you stop an instance in
an Auto Scaling group, it is marked Unhealthy
and replaced.
Set the health check grace period for a group
You can set the health check grace period for new and existing Auto Scaling groups.
Note
We strongly recommend also setting the default instance warm-up time for your Auto Scaling group. For more information, see Set the default instance warmup for an Auto Scaling group.