Scaling cooldowns for Amazon EC2 Auto Scaling
Important
As a best practice, we recommend that you do not use simple scaling policies and scaling cooldowns. A target tracking scaling policy or a step scaling policy is better for scaling performance. For a scaling policy that changes the size of your Auto Scaling group proportionally as the value of the scaling metric decreases or increases, we recommend target tracking over either simple scaling or step scaling.
When you create simple scaling policies for your Auto Scaling group, we recommend that you configure the scaling cooldown at the same time.
After your Auto Scaling group launches or terminates instances, it waits for a cooldown period to end before any further scaling activities initiated by simple scaling policies can start. The intention of the cooldown period is to let your Auto Scaling group stabilize and prevent it from launching or terminating additional instances before the effects of the previous scaling activity are visible.
Suppose, for example, that a simple scaling policy for CPU utilization recommends launching two instances. Amazon EC2 Auto Scaling launches two instances and then pauses the scaling activities until the cooldown period ends. After the cooldown period ends, any scaling activities initiated by simple scaling policies can resume. If CPU utilization breaches the alarm high threshold again, the Auto Scaling group scales out again, and the cooldown period takes effect again. However, if two instances were enough to bring the metric value back down, the group remains at its current size.
Contents
Considerations
The following considerations apply when working with simple scaling policies and scaling cooldowns:
-
Target tracking and step scaling policies can initiate a scale-out activity immediately without waiting for the cooldown period to end. Instead, whenever your Auto Scaling group launches instances, the individual instances have a warmup period. For more information, see Set the default instance warmup for an Auto Scaling group.
-
When a scheduled action starts at the scheduled time, it can also initiate a scaling activity immediately without waiting for the cooldown period to end.
-
If an instance becomes unhealthy, Amazon EC2 Auto Scaling does not wait for the cooldown period to end before replacing the unhealthy instance.
-
When multiple instances launch or terminate, the cooldown period (either the default cooldown or the scaling policy-specific cooldown) takes effect starting when the last instance finishes launching or terminating.
-
When you manually scale your Auto Scaling group, the default is not to wait for a cooldown to end. However, you can override this behavior and honor the default cooldown when you use the Amazon CLI or an SDK to manually scale.
-
By default, Elastic Load Balancing waits 300 seconds to complete the deregistration (connection draining) process. If the group is behind an Elastic Load Balancing load balancer, it will wait for the terminating instances to deregister before starting the cooldown period.
Lifecycle hooks can cause additional delays
If a lifecycle hook is invoked, the
cooldown period begins after you complete the lifecycle action or after the
timeout period ends. For example, consider an Auto Scaling group that has a lifecycle
hook for instance launch. When the application experiences an increase in
demand, the group launches an instance to add capacity. Because there is a
lifecycle hook, the instance is put into a wait state and scaling activities due
to simple scaling policies are paused. When the instance enters the
InService
state, the cooldown period starts. When the cooldown
period ends, simple scaling policy activities are resumed.
When Elastic Load Balancing is enabled, for the purposes of scaling in, the cooldown period starts when the instance that's selected for termination starts connection draining (deregistration delay). The cooldown period doesn't wait for connection draining to finish or the lifecycle hook to complete its action. This means that any scaling activities due to simple scaling policies can resume as soon as the result of the scale in event is reflected in the capacity of the group. Otherwise, waiting to complete all three activities—connection draining, a lifecycle hook, and a cooldown period— would significantly increase the amount of time that the Auto Scaling group needs to pause scaling.
Change the default cooldown period
You can't set the default cooldown when you initially create an Auto Scaling group in the Amazon EC2 Auto Scaling console. By default, this cooldown period is set to 300 seconds (5 minutes). If needed, you can update this after the group is created.
To change the default cooldown period (console)
After creating the Auto Scaling group, on the Details tab, choose Advanced configurations, Edit. For Default cooldown, choose the amount of time that you want based on your instance startup time or other application needs.
To change the default cooldown period (Amazon CLI)
Use the following commands to change the default cooldown for new or existing Auto Scaling groups. If the default cooldown is not defined, the default value of 300 seconds is used.
To confirm the value of the default cooldown, use the describe-auto-scaling-groups command.
Set a cooldown period for specific simple scaling policies
By default, all simple scaling policies use the default cooldown period that is defined for the Auto Scaling group. To set a cooldown period for specific simple scaling policies, use the optional cooldown parameter when you create or update the policy. When a cooldown period is specified for a policy, it overrides the default cooldown.
One common use for a scaling policy-specific cooldown period is with a scale in policy. Because this policy terminates instances, Amazon EC2 Auto Scaling needs less time to determine whether to terminate additional instances. Terminating instances should be a much quicker operation than launching instances. The default cooldown period of 300 seconds is therefore too long. In this case, a scaling policy-specific cooldown period with a lower value for your scale in policy can help you reduce costs by allowing the group to scale in faster.
To create or update simple scaling policies in the console, choose the Automatic scaling tab after you create the group. To create or update simple scaling policies using the Amazon CLI, use the put-scaling-policy command. For more information, see Step and simple scaling policies.