Temporarily remove instances from your Auto Scaling group
You can put an instance that is in the InService
state into the
Standby
state, update or troubleshoot the instance, and then return the
instance to service. Instances that are on standby are still part of the Auto Scaling group, but
they do not actively handle load balancer traffic.
This feature helps you stop and start the instances or reboot them without worrying about Amazon EC2 Auto Scaling terminating the instances as part of its health checks or during scale-in events.
For example, you can change the Amazon Machine Image (AMI) for an Auto Scaling group at any time by changing the launch template or launch configuration. Any subsequent instances that the Auto Scaling group launches use this AMI. However, the Auto Scaling group does not update the instances that are currently in service. You can terminate these instances and let Amazon EC2 Auto Scaling replace them, or use the instance refresh feature to terminate and replace the instances. Or, you can put the instances on standby, update the software, and then put the instances back in service.
Detaching instances from an Auto Scaling group is similar to putting instances on standby. Detaching instances might be useful if you want to attach them to a different group or manage the instances like standalone EC2 instances and possibly terminate them. For more information, see Detach or attach instances from your Auto Scaling group.
Contents
How the standby state works
The standby state works as follows to help you temporarily remove an instance from your Auto Scaling group:
-
You put an instance into the standby state. The instance remains in this state until you exit the standby state.
-
If there is a load balancer target group or Classic Load Balancer attached to your Auto Scaling group, the instance is deregistered from the load balancer. If connection draining is enabled for the load balancer, Elastic Load Balancing waits 300 seconds by default before completing the deregistration process, which helps in-flight requests to complete.
-
You can update or troubleshoot the instance.
-
You return the instance to service by exiting the standby state.
-
If there is a load balancer target group or Classic Load Balancer attached to your Auto Scaling group, the instance is registered with the load balancer.
For more information about the lifecycle of instances in an Auto Scaling group, see Amazon EC2 Auto Scaling instance lifecycle.
Considerations
The following are considerations when moving instances in and out of the standby state:
-
When you put an instance on standby, you can either decrement the desired capacity through this operation, or keep it the same value.
-
If you choose not to decrement the desired capacity of the Auto Scaling group, Amazon EC2 Auto Scaling launches an instance to replace the one on standby. The intention is to help you maintain capacity for your application while one or more instances are on standby.
-
If you choose to decrement the desired capacity of the Auto Scaling group, this prevents the launch of an instance to replace the one on standby.
-
-
After you put the instance back in service, the desired capacity is incremented to reflect how many instances are in the Auto Scaling group.
-
To do the increment (and decrement), the new desired capacity must be between the minimum and maximum group size. Otherwise, the operation fails.
-
If at anytime after putting an instance on standby, or returning the instance to service by exiting the standby state, your Auto Scaling group is found to not be balanced between Availability Zones, Amazon EC2 Auto Scaling compensates by rebalancing the Availability Zones unless you suspend the
AZRebalance
process. For more information, see Suspend and resume Amazon EC2 Auto Scaling processes. -
You are billed for instances that are in a standby state.
Health status of an instance in a standby state
Amazon EC2 Auto Scaling does not perform health checks on instances that are in a standby state. While the instance is in a standby state, its health status reflects the status that it had before you put it on standby. Amazon EC2 Auto Scaling does not perform a health check on the instance until you put it back in service.
For example, if you put a healthy instance on standby and then terminate it, Amazon EC2 Auto Scaling continues to report the instance as healthy. If you attempt to put a terminated instance that was on standby back in service, Amazon EC2 Auto Scaling performs a health check on the instance, determines that it is terminating and unhealthy, and launches a replacement instance. For more information, see Health checks for instances in an Auto Scaling group.
Temporarily remove an instance by setting it to standby
Use one of the following procedures to take an instance out of service temporarily by placing it into standby state.