This topic describes how to manage the lifecycle of ECS instances in a scaling group and lists all the possible service states of the instances. When Auto Scaling manages the ECS instance lifecycle, it checks whether ECS instances are healthy, and removes or even releases unhealthy instances.

Methods for managing the ECS instance lifecycle

ECS instances in a scaling group are categorized into automatically created and manually added instances based on how the instances are added to the scaling group. The following table describes the methods for managing the lifecycle of ECS instances in a scaling group.
Type Description Management method
Automatically created ECS instances Instances that are automatically created based on the instance configuration source of a scaling group. Auto Scaling manages the whole lifecycle of an ECS instance. During a scale-out event, Auto Scaling automatically creates ECS instances. During a scale-in event, Auto Scaling stops and releases ECS instances.
Manually added ECS instances Instances that are manually created and then added to a scaling group. The management method depends on whether the scaling group is enabled to manage the ECS instance lifecycle:
  • Enabled: During a scale-in event, ECS instances are stopped and released.
  • Not enabled: During a scale-in event, ECS instances are removed from the scaling group, but are not released.

Instance service states

The following table lists all possible service states of an ECS instance in a scaling group from when the instance is added to the scaling group to when the instance is removed from the scaling group.
Service state Description
Pending (Pending) The ECS instance is being added to a scaling group. During this process, Auto Scaling adds the ECS instance to the backend server groups of the associated Server Load Balancer (SLB) instances and the whitelists of the associated ApsaraDB for RDS instances.
Adding:Wait (Pending:Wait) If a lifecycle hook that applies to scale-out events is created for a scaling group, when the ECS instance is being added to the scaling group, the instance is put into the wait state until the lifecycle hook times out.
InService (InService) The ECS instance is added to a scaling group and can provide services normally.
Standby (Standby) The ECS instance is put out of service. Its weight as an SLB backend server is set to zero. Auto Scaling does not manage the instance lifecycle. You must manage it manually.
Protected (Protected) The ECS instance can provide services normally. However, Auto Scaling does not manage the instance lifecycle. You must manage it manually.
Stopped (Stopped) The ECS instance is stopped and put out of service.
Removing (Removing) The ECS instance is being removed from a scaling group. During this process, Auto Scaling removes the instance from the backend server groups of the associated SLB instances and from the whitelists of the associated ApsaraDB for RDS instances.
Removing:Wait (Removing:Wait) If a lifecycle hook that applies to scale-in events is created for a scaling group, when the ECS instance is being removed from the scaling group, the instance is put into the wait state until the lifecycle hook times out.

Instance health check

When Auto Scaling manages the lifecycle of ECS instances, it checks the running states of the instances on a regular basis. If Auto Scaling finds that an instance is not in the running state, this instance is considered to be unhealthy.
Note The running states of an ECS instance are not its service states in a scaling group. The running states refer to all possible states of an ECS instance from when the instance is created to when the instance is released. For more information, see ECS instance lifecycle.
The following section describes how Auto Scaling removes unhealthy ECS instances from a scaling group:
  • If the instances are automatically created by Auto Scaling, or are manually added to the scaling group and their lifecycle is managed by Auto Scaling, Auto Scaling removes and releases these instances.
  • If the instances are manually added to the scaling group and their lifecycle is not managed by Auto Scaling, Auto Scaling removes these instances from the scaling group but does not release them.
The removal of unhealthy ECS instances is not subject to the minimum number of instances in a scaling group. Therefore, the number of instances in the scaling group may be less than the minimum number of instances after the removal. Auto Scaling will automatically create a corresponding number of ECS instances to maintain the minimum number.
Warning Make sure that you have sufficient balance in your account. If you have overdue payments in your account, pay-as-you-go and preemptible instances will be stopped or even released. For information about status changes of ECS instances with overdue payments, see Overdue payments.