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:
  • Make sure that the following requirements are met if you want to associate an Application Load Balancer (ALB) server group with a scaling group:
  • Make sure that the following requirements are met if you want to associate an ApsaraDB RDS instance with a scaling group:

Background information

ECS instances can be used as configuration sources to create scaling groups regardless of the billing method. Subscription instances, pay-as-you-go instances, or preemptible instances can all be used as configuration sources. After a scaling group is created based on an ECS instance, the system creates a default scaling configuration of which the billing method is pay-as-you-go.
Note This default scaling configuration uses the base image used by the ECS instance, instead of creating a custom image from the instance. If you want the scaling configuration to use an image that contains all the system configurations and data of an existing ECS instance, create a custom image from the ECS instance and then use the created custom image to update the scaling configuration. For more information, see Image update in scaling configurations.

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

  1. Open the Create Scaling Group dialog box.
    1. Log on to the ECS console.
    2. In the left-side navigation pane, choose Instances & Images > Instances.
    3. In the top navigation bar, select a region.
    4. Find the ECS instance that you want to use as the configuration source. In the Actions column, choose More > Deployment & Elasticity > Create Scaling Group.
  2. 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 resources in the scaling group. Auto Scaling scales instances based on the Type parameter. Valid values:
    • ECS: ECS instances
    • ECI: elastic container instances
    Instance Configuration Source Auto Scaling creates instances based on the Instance Configuration Source parameter. Valid values:
    • Launch Template: A launch template contains information such as the key pair, RAM role, instance type, and network settings. A launch template does not contain passwords. Launch Template is available only if you set Type to ECS.

      If you use Launch Template, you must configure the Select Launch Template parameter and the Select Template Version parameter. To meet diverse business requirements, you can use the Extend Launch Template Configurations parameter to select multiple instance types. For more information about how to configure weights for instance types, see Use performance metrics to measure Auto Scaling.

    • Select Existing Instance: Select an existing instance. After you select an instance, Auto Scaling extracts the basic configurations of the instance to create a default scaling configuration.

      If you set Type to ECS, the basic configurations that are extracted from the selected ECS instance include the instance type, network type, security group, and base image. The instance logon password and tags are not extracted. The base image is the image used by the existing instance. The base image does not include instance data such as application data. If you want to include all system configurations of the instance and instance data in the scaling configuration, create a custom image for the instance and use the custom image to update the image of the scaling configuration. For more information, see Image update in scaling configurations.

    • Create from Scratch: Do not specify a template that is used to automatically create instances. After you create a scaling group, create a scaling configuration or specify a launch template.
    Note When you create a scaling group that contains ECS instances created in the ECS console, the instance configurations and network type of the instances are automatically populated. We recommend that you use the default settings.
    Tag You can add tags to help you find and manage scaling groups. For more information, see Overview.
    Note The tags that you add 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 in the launch template.
    Scale-In Policy If you need to remove more than one instance from a scaling group, Auto Scaling removes instances based on the Scale-In Policy parameter. If multiple instances meet the conditions of the policy, a random instance is removed. The Scale-In Policy parameter is available only if you set Type to ECS.
    The Scale-In Policy parameter contains the First Remove and Then Remove fields. Specify different values for the two fields. The following part describes the values.
    Note If you set Type 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 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 launch template. No scaling configuration or launch template is associated with manually added instances. 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 launch template is associated, Auto Scaling removes manually added instances at random.
      Note Scaling Configuration in Earliest Instance Created Using Scaling Configuration specifies the instance configuration source that contains the scaling configuration and launch template.

      The version of a launch template does not indicate the sequence in which the template is added. For example, you use the lt-foress V2 template to create a scaling group, and then you replace the template with the lt-foress V1 template when you modify the scaling group. In this case, the scaling group 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 value is available only for the Then Remove field. If you select No Policy, Auto Scaling does not remove instances from the results obtained based on the First Remove field.
    If Auto Scaling removes instances based on the Earliest Instance Created Using Scaling Configuration value, you can select one of the following values for the Then Remove field:
    • No Policy: Auto Scaling does not remove instances from the results 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 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 obtained based on the First Remove field.
    Note The value of the Scaling Policy parameter affects how instances are removed from scaling groups. For more information about how to remove instances from scaling groups, see Configure a combination policy for removing instances.
    Suspend Processes 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, the instance is not removed from the scaling group if the health check fails. You can suspend the following processes for a scaling group:
    • Scale-out: If you suspend this process, Auto Scaling rejects all scale-out requests.
    • Scale-in: If you suspend this process, Auto Scaling rejects all scale-in requests.
    • Health Check: If you suspend this process, Auto Scaling suspends the health check process and does not remove unhealthy instances.
    • Scheduled Task: When the execution time of a scheduled task arrives, the scaling rules that are associated with the task are not triggered.
    • Event-triggered Task: When an event-triggered task enters the alert state, the scaling rules that are associated with the task are not triggered.

    For more information, see Suspend and resume scaling processes.

    Deletion Protection After you enable this feature, you cannot delete the scaling group by using the Auto Scaling console or by calling API operations.
    Instance Health Check After you enable this feature, Auto Scaling checks the status of instances on a regular basis. If an instance is not running, the instance is considered unhealthy and is removed from the scaling group. For more information, see Instance lifecycles.
    Minimum Number of Instances If the number of instances in a scaling group is less than the minimum number of instances allowed, Auto Scaling automatically creates instances until the number of instances in the scaling group reaches the minimum number.
    Maximum Number of Instances If the number of instances in a scaling group is greater than the maximum number of instances allowed, Auto Scaling automatically removes instances until the number of instances in the scaling group does not exceed the maximum number.
    Expected Number of Instances If you specify an expected number of instances, Auto Scaling automatically maintains the specified number of instances. 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 for a scaling group after you create it.
    Default Cooldown Time (Seconds) Specifies the default cooldown time of a scaling group. Unit: seconds. During the cooldown time, Auto Scaling rejects all requests for scaling activities 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 time 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 Network Type to VPC.
    Note When you create a scaling group that contains ECS instances created in the ECS console, the instance configurations and network type of the instances are automatically populated. We recommend that you use the default 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 Type to ECS and Network Type to VPC. Valid values:
    • Priority Policy: Instances are preferentially created in the zone where the vSwitch that has the highest priority resides. Auto Scaling preferentially scales instances in the zone where the vSwitch that has the highest priority resides. If the scaling fails, Auto Scaling attempts to scale instances in the zone where the vSwitch that has the next highest priority resides.
      Note If you set Type 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 more than two zones. Auto Scaling evenly distributes instances across the zones where the vSwitches reside based on this policy. If instances are not evenly distributed across multiple zones due to insufficient resources, you can use Balanced Distribution Policy to re-distribute instances across 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 activity is triggered, Auto Scaling preferentially creates ECS instances that have the lowest vCPU price. When a scale-in activity is triggered, Auto Scaling preferentially removes ECS instances that have the highest vCPU price. If you select 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 Minimum Pay-as-you-go Instances, 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 among 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 you specified for the scaling group.
    • Lowest Cost Instance Types: the number of the instance types that have the lowest price. Default value: 1. This parameter is valid 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 the Supplemental Preemptible Instances 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. After you enable this feature, Auto Scaling attempts to create pay-as-you-go instances to meet the required number of preemptible instances if preemptible instances cannot be created due to factors such as high prices and insufficient resources.
    Instance Reclaim Mode The Instance Reclaim Mode parameter is available only if you set Type to ECS and Network Type to VPC. Valid values:
    • Release: Instances that are removed from the scaling group are released. Resources of these instances are not retained. During a scale-out activity, Auto Scaling creates new instances and adds the instances to the scaling group.
      Note If you set Type to ECI, instances that are removed from the scaling group are released by default.
    • Economical Mode: ECS instances that are removed from the scaling group are stopped and enter Economical Mode. Some resources of the ECS instances are retained, and you are charged for these resources. During a scale-out activity, Auto Scaling preferentially adds the stopped ECS instances to the scaling group. After all stopped ECS instances are added, Auto Scaling determines whether to create ECS instances and add them to the scaling group based on your scale-out requirements. The Economical Mode setting can improve scaling efficiency. For more information, see Use the Economical Mode feature to scale instances faster.
      Notice
      • Your data stored on instances may be lost when the instances are reclaimed. To prevent data loss, do not store application data or logs on instances.
      • Stopped instances may be released due to the following reasons:
        • If the total number of instances in a scaling group exceeds the maximum number of instances allowed for the scaling group after you manually reduce the maximum number, Auto Scaling preferentially releases the ECS instances that are in the Stopped state.
        • If stopped instances fail to be added to a scaling group due to insufficient resources or overdue payments, the instances are released.
      • For more information about the Economical Mode setting, see the "Prerequisites", "Application resources", and "Trigger effects" sections in the Economical mode topic.
    VPC Select an existing VPC.
    Note When you create a scaling group that contains ECS instances created in the ECS console, the instance configurations and network type of the instances are automatically populated. We recommend that you use the default settings.
    Select vSwitch After you select a VPC, you must select a vSwitch. Each vSwitch resides in a single zone. To deploy instances across multiple zones, you must specify multiple vSwitches in different zones. We recommend that you select multiple zones to increase the success rate of scale-out.
    Note When you create a scaling group that contains ECS instances created in the ECS console, the instance configurations and network type of the instances are automatically populated. We recommend that you use the default settings.
    Add Existing Instance The Add Existing Instance parameter is available only if you set Type to ECS and set Instance Configuration Source to Launch Template or Select Existing Instance.

    If you specify an expected number of instances and then add existing instances to a scaling group, the expected number of instances for the scaling group automatically increases. For example, when you create a scaling group, you set Expected Number of Instances to 1 and add two existing instances to the scaling group. In this case, the expected number of instances is three.

    You can select Enable the scaling group to manage the instance lifecycle.
    • If the scaling group manages the lifecycle of instances, the instances are automatically released when the instances are manually removed from the scaling group or are considered unhealthy.
    • If the scaling group does not manage the lifecycle of instances, the instances are not automatically released when the instances are removed from the scaling group.
    Note You can add subscription instances to a scaling group. However, the lifecycle of the subscription instances cannot be managed by the scaling group.
    Associate CLB Instance After you associate a CLB instance with a scaling group, the instances that you add to the scaling group are automatically added as the backend servers of the CLB instance. Then, the CLB instance forwards requests to the instances.

    You can specify a server group to which you want 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 different backend servers 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 these 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 the Quota Center.
    Associate ALB Server Group The Associate ALB Server Group parameter is available only if you set Network Type to VPC. After you associate an ALB server group with a scaling group, the instances that you add to the scaling group are automatically added to the ALB server group to process requests that are forwarded by the ALB instance. 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 increases. If you set the weight to 0, no requests are forwarded to the server.

    If you associate multiple ALB server groups with the same scaling group, all instances that you add to the scaling group are added to the server groups.

    Note You can associate only a limited number of ALB server groups with a scaling group. To view the quota or request a quota increase, go to the Quota Center.
    Associate ApsaraDB RDS Instance The Associate ApsaraDB RDS Instance parameter is available only if you set Type to ECS. After you associate an ApsaraDB RDS instance with a scaling group, the internal IP addresses of ECS instances that you add to the scaling group are automatically added to the whitelist that manages access to the ApsaraDB RDS instance to allow internal communication.
    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 the Quota Center.
    Configure Notification When a scaling activity succeeds, fails, or is rejected, Auto Scaling sends notifications to you by using text messages, internal messages, or emails. For more information, see Create a regular notification rule.
  3. In the Create Scaling Group dialog box, click OK.
  4. On the Scaling Groups page, find the scaling group that you created and choose more > Enable 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.

What to do next

You can manually add, remove, or delete ECS instances for the scaling group. Alternatively, you can configure scheduled tasks or event-triggered tasks to automatically scale the scaling group. For more information, see the following topics: