After you create a scaling group based on an Elastic Compute Service (ECS) instance, the system creates a default scaling configuration. This simplifies the preparations required to enable the scaling group and allows you to quickly use the scaling group.
Prerequisites
- Make sure that the following requirements are met if you want to associate a Classic Load Balancer (CLB) instance with a scaling group:
- One or more CLB instances are created. At least one CLB instance is in the Active state. For information about how to create CLB instances, see Create and manage a CLB instance.
- The CLB instance must reside in the same region as the scaling group.
- If the network types of the CLB instance and the scaling group are both virtual private cloud (VPC), the CLB instance and the scaling group must reside in the same VPC.
- If the network type of the CLB instance is classic network, the network type of the scaling group is VPC, and the backend server group of the CLB instance contains ECS instances that reside in a VPC, the ECS instances and the scaling group must reside in the same VPC.
- The CLB instance is configured with at least one listener. For information about how to configure listeners for CLB instances, see Listener overview.
- The health check feature is enabled for the CLB instance. For information about how to enable the health check feature for CLB instances, see Configure and manage health checks.
- Make sure that the following requirements are met if you want to associate an Application Load Balancer (ALB) server group with a scaling group:
- The network type of the scaling group must be VPC. The scaling group and the ALB or NLB server group must reside in the same VPC.
- The ALB or NLB server group is in the Available state.
- Make sure that the following requirements are met if you want to associate an ApsaraDB RDS instance with a scaling group:
- One or more ApsaraDB RDS instances are created. At least one ApsaraDB RDS instance is in the Running state. For information about how to create ApsaraDB RDS instances, see What is ApsaraDB RDS?.
- The ApsaraDB RDS instance must reside in the same region as the scaling group.
Background information
After a scaling group is created, you can manually add existing ECS instances or configure ECS instances to be automatically added to the scaling group. Only pay-as-you-go and preemptible ECS instances can be automatically created for scaling groups, whereas subscription, pay-as-you-go, and preemptible instances can be manually added to scaling groups. For more information about limits on scaling groups, see Limits.
Procedure
- Open the Create Scaling Group dialog box.
- Log on to the ECS console.
- In the left-side navigation pane, choose .
- In the top navigation bar, select a region.
- Find the ECS instance that you want to use as the configuration source. In the Actions column, choose .
- In the Create Scaling Group dialog box, configure parameters and click OK. If you create a scaling group from scratch, you must manually specify all parameters. If you create a scaling group based on an existing ECS instance, the following parameters are automatically specified:
- Instance Configuration Source: is set to Select Existing Instance. The system extracts the configurations of your selected existing ECS instance to create a default scaling configuration template and uses the scaling configuration template to create ECS instances in the scaling group. The extracted ECS instance configurations include the instance type, base image, network type, security groups, logon password, and tags. If some of the ECS instance configurations such as the image do not meet your business requirements, you can modify the scaling configurations after the scaling group is created.
- Network Type: is set to the network type of the selected ECS instance.
- VPC ID: is set to the virtual private cloud (VPC) ID of the selected ECS instance if the instance is deployed in a VPC.
- VSwitch ID: is set to the ID of the vSwitch to which the selected ECS instance is connected if the instance is deployed in a VPC.
The following table describes the parameters required to create a scaling group. Accept the values automatically specified for parameters.Parameter Description Scaling Group Name The name of a scaling group must be 2 to 64 characters in length, and can contain letters, digits, periods (.), underscores (_), and hyphens (-). The name must start with a letter or a digit. Type The type of instances that provide computing power in the scaling group. The type of instances that Auto Scaling adds to or removes from the scaling group during a scaling activity is also determined by the value of the Type parameter. Valid values: - ECS: ECS instances
- ECI: elastic container instances
Instance Configuration Source Auto Scaling creates instances based on the value of the Instance Configuration Source parameter. Valid values: - Launch Templates: A launch template contains information such as the key pair, RAM role, instance type, and network settings. A launch template does not contain passwords. The Launch Templates setting is available only if you set the Type parameter to ECS.
If you set the Instance Configuration Source parameter to Launch Templates, you must also configure the Select Launch Template and Select Template Version parameters. To meet diverse business requirements, you can specify multiple instance types in the Extend Configurations of Launch Template section. For information about how to configure weights for instance types, see Use performance metrics to measure Auto Scaling.
- Select Existing Instance: You must select an existing instance. Auto Scaling extracts the basic configurations of the selected instance to create a default scaling configuration.
If you set the Type parameter to ECS, the basic configurations that are extracted from the selected instance include the instance type, network type, security group, and base image. The instance logon password and tags are not included. The base image is the image that is used by the existing instance. The base image does not provide instance data such as application data. If you want to obtain both system configurations and application data of the selected instance, create a custom image for the instance and use the custom image to replace the base image in the scaling configuration. For more information, see Image update in scaling configurations.
- Create from Scratch: You can continue creating the scaling group, without the need to specify a template. You need to specify a scaling configuration or launch template only after you create the scaling group. The steps that you must perform to create a scaling configuration vary based on the value of the Type parameter. For more information, see Create scaling configurations for scaling groups that contain ECS instances and Create scaling configurations for scaling groups that contain elastic container instances.
Note If you create a scaling group based on ECS instances in the ECS console, Auto Scaling automatically configures the instance configuration source and network type. We recommend that you do not modify the settings.Tag You can add tags to help you find and manage scaling groups. For more information, see Overview. Note The tags apply only to the scaling group. If you want to add tags to an instance in the scaling group, specify the tags in the scaling configuration or the launch template based on which the instance is created.Tags Propagated to Instances During Scale-out After you add one or more tags to the scaling group, you can continue to specify tags that you want to add to instances during scale-outs. Scale-In Policy If you want to remove instances from the scaling group by step, you can configure this parameter. If multiple instances meet the removal conditions after the scale-in policy takes effect, a random instance is removed. This parameter is available only if you set the Type parameter to ECS. The Scale-In Policy parameter contains the First Remove and Then Remove fields. Specify different values for the two fields. Valid values:Note If you set the Type parameter to ECI, Auto Scaling removes the instances that are created based on the earliest scaling configuration. Then, Auto Scaling removes the instances that are created at the earliest point in time from the results that are obtained based on the First Remove field.- Earliest Instance Created Using Scaling Configuration: Auto Scaling removes instances that are created based on the earliest scaling configuration or the earliest launch template. No scaling configuration or launch template is associated with instances that are manually added to the scaling group. Therefore, manually added instances are not removed first. If more instances need to be removed from a scaling group after Auto Scaling removes all instances with which the earliest scaling configuration or the earliest launch template is associated, Auto Scaling removes manually added instances in a random manner. Note The scaling configuration source in the Earliest Instance Created Using Scaling Configuration setting can be a scaling configuration or a launch template.
The version of a launch template does not indicate the order in which the template is added. For example, if you specify the lt-foress V2 launch template when you create a scaling group, and then replace the template with the lt-foress V1 launch template when you modify the scaling group, Auto Scaling considers the lt-foress V2 launch template as the earliest template.
- Earliest Created Instance: Auto Scaling removes the instances that are created at the earliest point in time.
- Most Recent Created Instance: Auto Scaling removes the instances that are created at the latest point in time.
- No Policy: This setting is available only for the Then Remove field. If you select No Policy, Auto Scaling does not remove instances from the results that are obtained based on the First Remove field.
If Auto Scaling removes instances based on the Earliest Instance Created Using Scaling Configuration setting, you can set the Then Remove field to one of the following values:- No Policy: Auto Scaling does not remove instances from the results that are obtained based on the First Remove field.
- Earliest Created Instance: Auto Scaling removes the instances that are created at the earliest point in time from the results that are obtained based on the First Remove field.
- Most Recent Created Instance: Auto Scaling removes the instances that are created at the latest point in time from the results that are obtained based on the First Remove field.
Note The value of the Scaling Policy parameter also affects the manner in which instances are removed from scaling groups. For information about how to remove ECS instances from scaling groups, see Configure a combination policy for removing instances.Suspend Process You can suspend processes before you perform specific operations. For example, you can suspend the health check process before you stop an instance. This way, if the health check fails, the instance is not removed from the scaling group. You can suspend the following processes in a scaling group: - Scale-out: If you suspend this type of process, Auto Scaling rejects all scale-out requests.
- Scale-in: If you suspend this type of process, Auto Scaling rejects all scale-in requests.
- Health Check: If you suspend this type of process, Auto Scaling suspends the health checks and does not remove unhealthy instances.
- Scheduled Task: If you suspend this type of process, scaling rules that are associated with a scheduled task are not executed when the execution time of the scheduled task arrives.
- Event-triggered Task: If you suspend this type of process, scaling rules that are associated with an event-triggered task are not executed when the event-triggered task enters the Alert state.
For more information, see Suspend and resume scaling processes.
Deletion Protection After you enable this feature, you cannot delete the scaling group in the Auto Scaling console or by calling API operations. This helps prevent accidental deletion of scaling groups. Instance Health Check After you enable this feature, Auto Scaling checks the status of instances on a regular basis. If Auto Scaling detects that an instance does not run as expected, Auto Scaling considers the instance unhealthy and removes the instance from the scaling group. For more information, see Instance lifecycles. Minimum Number of Instances If the number of instances in the scaling group is less than the value of this parameter, Auto Scaling adds instances until the number of instances in the scaling group reaches the minimum number. Maximum Number of Instances If the number of instances in the scaling group is greater than the value of this parameter, Auto Scaling removes instances until the number of instances in the scaling group does not exceed the maximum number. Expected Number of Instances If you enable the Expected Number of Instances feature for the scaling group, Auto Scaling maintains the expected number of instances in the scaling group. For more information, see Expected number of instances. Note You can enable the Expected Number of Instances feature only when you create a scaling group. You cannot enable the Expected Number of Instances feature after you create the scaling group.Maximum Life Span of Instance (Seconds) The maximum life span of an instance in the scaling group. After the specified life span of the instance elapses, Auto Scaling creates a new instance to replace the instance. This parameter is available only if you set the Type parameter to ECS.
Default Cooldown Time (Seconds) The cooldown period of the scaling group after a scaling activity is complete. During the cooldown period, Auto Scaling rejects all scaling requests that are triggered by event-triggered tasks. Scaling activities that are triggered by other types of tasks, such as scheduled tasks and manually executed tasks, are not subject to the cooldown period and can be immediately executed. Network Type The Scaling Policy, Instance Reclaim Mode, and Associate ALB Server Group parameters are available only if you set the Network Type parameter to VPC. Note If you create a scaling group based on ECS instances in the ECS console, Auto Scaling automatically configures the instance configuration source and network type. We recommend that you do not modify the settings.A scaling group and instances in the scaling group must belong to the same network type. For example, if a scaling group resides in a VPC, the instances in the scaling group must also reside in the VPC. If a scaling group resides in the classic network, the instances in the scaling group must also reside in the classic network.
Note After you create a scaling group, you cannot change the network type of the scaling group.Scaling Policy The Scaling Policy parameter is available only if you set the Type parameter to ECS and the Network Type parameter to VPC. Valid values: - Priority Policy: Auto Scaling preferentially creates instances in the zone where the vSwitch that has the highest priority resides. If the scaling fails, Auto Scaling creates instances in the zone where the vSwitch that has the next highest priority resides. Note By default, if you set the Type parameter to ECI, Priority Policy is used.
- Balanced Distribution Policy: This policy is valid only if the scaling group is associated with multiple vSwitches that are distributed across two or more zones. Auto Scaling evenly distributes instances across the zones where the vSwitches reside based on the policy. If instances are not evenly distributed across multiple zones due to insufficient resources, you can use Balanced Distribution Policy to evenly redistribute instances across the zones. For more information, see Rebalance the distribution of ECS instances.
- Cost Optimization Policy: This policy is valid only if you specify multiple instance types in the scaling configuration. When a scale-out is triggered, Auto Scaling preferentially creates ECS instances that have the lowest-priced vCPUs. When a scale-in is triggered, Auto Scaling preferentially removes ECS instances that have the highest-priced vCPUs from the scaling group. If you specify Preemptible Instance as the billing method in the scaling configuration, Auto Scaling preferentially creates preemptible instances. If preemptible instances cannot be created due to insufficient resources, Auto Scaling creates pay-as-you-go instances. If you select Cost Optimization Policy, configure the following parameters based on your business requirements:
- Minimum Pay-as-you-go Instances: the minimum number of pay-as-you-go ECS instances in the scaling group. Default value: 0. If the number of pay-as-you-go ECS instances in the scaling group is less than the value of this parameter, Auto Scaling preferentially creates pay-as-you-go instances.
- Percentage of Pay-as-you-go Instances: the percentage of pay-as-you-go ECS instances in all automatically created instances. Default value: 70%. When you calculate this percentage, the pay-as-you-go ECS instances do not include the minimum number of pay-as-you-go ECS instances that is specified by the Minimum Pay-as-you-go Instances parameter.
- Lowest Cost Instance Types: the number of instance types that have the lowest price. Default value: 1. This parameter takes effect only if multiple instance types are specified in the scaling configuration. Auto Scaling evenly creates preemptible ECS instances of the instance types that are provided at the lowest price.
- Enable Supplemental Preemptible Instances: After you enable this feature, Auto Scaling automatically creates preemptible instances five minutes before the existing instances are reclaimed.
- Use Pay-as-you-go Instances to Supplement Preemptible Capacity: By default, this feature is enabled. Auto Scaling creates pay-as-you-go instances to meet the requirement on the number of preemptible instances when preemptible instances cannot be created due to factors such as cost-related issues and insufficient resources.
- Custom Combination Policy: You can create a custom scaling policy. If you want to adjust the ratio of pay-as-you-go instances to preemptible instances, balance the instance distribution between multiple zones, or select desired instance types, you can set the Scaling Policy parameter to Custom Combination Policy.
Instance Reclaim Mode The Instance Reclaim Mode parameter is available only if you set the Type parameter to ECS and the Network Type parameter to VPC. Valid values: - Release: releases instances that are removed from the scaling group. In this case, no resources are retained. If a scale-out is triggered, Auto Scaling creates new instances and adds the instances to the scaling group. Note By default, if you set the Type parameter to ECI, elastic container instances that are removed from the scaling group are released.
- Economical Mode: stops instances that are removed from the scaling group in Economical Mode. In this case, you are still charged for specific resources that are retained. If a scale-out is triggered, Auto Scaling preferentially adds the instances that are stopped in Economical Mode to the scaling group. If the number of instances that are stopped in Economical Mode does not meet the scale-out requirement, Auto Scaling creates and adds new instances. The Economical Mode setting helps improve the efficiency of scaling. For more information, see Use the Economical Mode feature to scale instances faster. Important
- Data that is stored on instances may be lost when the instances are reclaimed. To prevent data loss, do not store application data or logs on instances.
- In the following scenarios, instances that are stopped in Economical Mode may be released:
- If you manually modify the value of the Maximum Number of Instances parameter of the scaling group and the number of instances in all status in the scaling group is less than the new value of the Maximum Number of Instances parameter, Auto Scaling preferentially releases instances that are stopped in Economical Mode.
- If your Alibaba Cloud account has overdue payments or insufficient resources, instances that are stopped in Economical Mode may fail to be added to the scaling group during a scale-out. In this case, Auto Scaling may release the failed instances.
- For more information about the Economical Mode feature, see the "Prerequisites", "Application resources", and "Trigger effects" sections in the Economical mode topic.
VPC Select an existing VPC. Note If you create a scaling group based on ECS instances in the ECS console, Auto Scaling automatically configures the instance configuration source and network type. We recommend that you do not modify the settings.vSwitch After you select a VPC, you must select one or more vSwitches. Each vSwitch resides in a single zone. To deploy instances across multiple zones, you can specify multiple vSwitches. We recommend that you select multiple zones to increase the success rate of scale-outs. Note If you create a scaling group based on ECS instances in the ECS console, Auto Scaling automatically configures the instance configuration source and network type. We recommend that you do not modify the settings.Add Existing Instance The Add Existing Instance parameter is available only if you set the Type parameter to ECS and set the Instance Configuration Source parameter to Launch Template or Select Existing Instance. If you configure the Expected Number of Instances and Add Existing Instance parameters at the same time, the value of the Expected Number of Instances parameter automatically increases. For example, if you set the Expected Number of Instances parameter to 1 and set the Add Existing Instance parameter to 2 when you create a scaling group, the value of the Expected Number of Instances parameter automatically increases from 1 to 3.
You can select Enable the scaling group to manage the instance lifecycle.- If you enable the scaling group to manage the instance lifecycle, Auto Scaling may remove instances that are considered unhealthy. Auto Scaling may also release the instances that you manually remove from the scaling group.
- If you do not enable the scaling group to manage the instance lifecycle, Auto Scaling does not release instances that are removed from the scaling group.
Note You can add subscription instances to the scaling group, but you cannot enable the scaling group to manage the lifecycle of the subscription instances.Associate CLB Instance After you associate a CLB instance with a scaling group, Auto Scaling adds the instances in the scaling group to the backend server groups of the CLB instance as backend servers. Then, the CLB instance forwards requests to the backend servers. You can specify the following types of server groups to add instances. Valid values:
- Default server group: the group of instances that are used to receive requests. If you do not specify a vServer group or a primary/secondary server group for a listener, requests are forwarded to the instances in the default server group.
- vServer group: If you want to forward requests to backend servers that are not in the default server group or configure domain name- or URL-based routing methods, you can use vServer groups.
If you specify the default server group and multiple vServer groups at the same time, the instances are added to all specified server groups.
Note You can associate only a limited number of CLB instances and vServer groups with a scaling group. To view the quota or request a quota increase, go to Quota Center.Associate ALB and NLB Server Groups The Associate ALB and NLB Server Groups parameter is available only if you set the Network Type parameter to VPC. After you associate an ALB or NLB server group with a scaling group, Auto Scaling adds the instances in the scaling group to the ALB or NLB server group as backend servers. Then, the ALB or NLB instance forwards requests to the backend servers. You must specify the port number and weight for each backend server. By default, the weight of a backend server is 50. If you increase the weight of a server, the number of requests that are forwarded to the server also increases. If you set the weight of a backend server to 0, no requests are forwarded to the server. If you associate multiple ALB or NLB server groups with the same scaling group, Auto Scaling adds instances in the scaling group to all the associated ALB or NLB server groups at the same time.
Note You can associate only a limited number of ALB or NLB server groups with a scaling group. To view the quota or request a quota increase, go to Quota Center.Associate ApsaraDB RDS Instance The Associate ApsaraDB RDS Instance parameter is available only if you set the Type parameter to ECS. After you associate an ApsaraDB RDS instance with a scaling group, Auto Scaling adds the private IP addresses of the ECS instances in the scaling group to the IP address whitelist of the ApsaraDB RDS instance. This way, the ECS instances in the scaling group can communicate with the ApsaraDB RDS instance over an internal network. Note You can associate only a limited number of ApsaraDB RDS instances with a scaling group. To view the quota or request a quota increase, go to Quota Center.Create Regular Rule When a scaling activity succeeds, fails, or is rejected, Auto Scaling notifies you by text messages, internal messages, or emails based on the rule. For more information, see Create a regular notification rule. Synchronize Alert Rule to CloudMonitor You can enable or disable this feature only when you create a scaling group. After you enable this feature, Alibaba Cloud creates and associates a CloudMonitor application group with the scaling group. The alert rules of the scaling group are displayed in the CloudMonitor console in a synchronous manner. - In the Create Scaling Group dialog box, click OK.
- On the Scaling Groups page, find the scaling group that you created and choose in the Actions column. After the scaling group is enabled, Auto Scaling maintains a collection of ECS instances based on the settings of the scaling group such as the instance configuration source and minimum number of instances. For example, if the minimum number of instances is set to a non-zero value, Auto Scaling creates a corresponding number of ECS instances in the scaling group to ensure that the actual number of instances in the scaling group is greater than or equal to the minimum number.