This topic describes how to create a scaling group. A scaling group is a group of ECS instances that are dynamically scaled based on the preconfigured rules. A scaling group allows you to set the minimum and maximum numbers of ECS instances, automatically create ECS instances based on preconfigured templates, and specify the policies for removing ECS instances. You can use a scaling group to maintain a group of ECS instances based on your business requirements.

Prerequisites

  • To use an instance launch template to create ECS instances, you must first create an instance launch template. For more information, see Create a launch template.
  • Before you associate a scaling group with SLB instances, make sure that the following conditions are met:
    • You have at least one SLB instance in the Running state. For more information, see Create an SLB instance.
    • The SLB instance and the scaling group are in the same region.
    • The SLB instance and the scaling group are in the same Virtual Private Cloud (VPC) network if their network type is VPC.
    • If the network type of the SLB instance is classic network, the network type of the scaling group is VPC, and the back-end server group of the SLB instance contains VPC-connected ECS instances, then the ECS instances and the scaling group must be in the same VPC network.
    • At least one listener is configured on the SLB instance. For more information, see Listener overview.
    • Health check is enabled on the SLB instance. For more information, see Configure health check.
  • Before you associate a scaling group with ApsaraDB for RDS instances, make sure that the following conditions are met:
    • At least one ApsaraDB for RDS instance is in the Running state. For more information, see What is ApsaraDB for RDS?.
    • The ApsaraDB for RDS instances and the scaling group must reside in the same region.

Background information

You can create only a limited number of scaling groups. For more information, see Limits.

Procedure

  1. Log on to the Auto Scaling console.
  2. In the upper-right corner of the Scaling Groups page, click Create Scaling Group.
  3. Configure the instance template source for the scaling group.
    1. Select a source type.
      Option Description
      Select Instance Launch Template Uses an instance launch template to create ECS instances.
      Select Existing Instance Uses the configuration of an existing ECS instance as a template to create ECS instances. The configuration contains instance type, image, network type, security group, logon password, and tags.
      Create from Scratch Creates a scaling group without specifying a template. After the scaling group is created, it is in the Disabled state. Before you enable the scaling group, create a scaling configuration or specify an instance launch template used to create ECS instances.
    2. Optional:Specify the required parameters based on the type of the instance template.
      • If the type of the instance template is set to Select Instance Launch Template, select an existing instance launch template and a template version.
      • If the type of the instance template is set to Select Existing Instance, select an existing ECS instance.
  4. Configure basic information of the scaling group.
    1. Specify the scaling group name.
    2. Specify the number of instances in the scaling group.
      Parameter Description
      Maximum Number of Instances When the number of existing ECS instances is greater than the maximum number of instances, Auto Scaling automatically removes ECS instances from the scaling group to maintain the maximum number.
      Minimum Number of Instances When the number of existing ECS instances is less than the minimum number of instances, Auto Scaling automatically adds instances to the scaling group to maintain the minimum number.
      Expected Number of Instances Auto Scaling automatically keeps the number of ECS instances at the expected level. For more information, see Expected Instances.
    3. Specify the default cooldown time.
      The Default Cooldown Time parameter specifies the default cooldown time of a scaling group in seconds. During the cooldown time, the scaling group rejects all scaling activity requests triggered by event-triggered tasks from Cloud Monitor. However, scaling activities triggered by other types of tasks, such as scheduled tasks and manually executed tasks, are not subject to the cooldown time and are executed immediately.
    4. Optional:Specify the instance removing policy.
      This policy is used to filter and remove ECS instances from a scaling group based on multiple filter conditions. If multiple ECS instances meet the conditions of the policy, one instance is removed at random.
      The Instance Removing Policy parameter contains Filter First and Then Remove from Results. You cannot specify the same value for Filter First and Then Remove from Results. The following table describes the options for the instance removing policy.
      Option Description
      Earliest Instance Created Using Scaling Configuration The scaling configuration refers to the instance configuration source that contains the scaling configuration and instance launch template.

      Auto Scaling filters instances to find the ones that use the earliest scaling configuration and instance launch template. Manually added instances are not associated with scaling configurations or instance launch templates. Therefore, manually added instances are not found first. If all associated instances have been removed but Auto Scaling must remove more instances from the scaling group, manually added instances are removed at random.

      The version of an instance launch template does not indicate the order in which the template was added. For example, you select the lt-foress V2 template when you create a scaling group. Then, you select the lt-foress V1 template to modify the scaling group. The scaling group considers the lt-foress V2 launch template as the template that was added earlier.

      Earliest Created Instance Auto Scaling filters instances to find the ones that were created at the earliest points in time.
      Most Recent Created Instance Auto Scaling filters instances to find the ones that were created most recently.
      No Policy This option is available only for Then Remove from Results. This option indicates that Auto Scaling does not filter instances in the second step.
      For example, if Auto Scaling filters instances based on Earliest Instance Created Using Scaling Configuration in the first step, then you can select one of the following options in the second step:
      • No Policy: This option indicates that Auto Scaling does not filter instances in the second step.
      • Earliest Created Instance: Auto Scaling filters instances to find the ones that were created at the earliest points in time from the filtering results in the first step.
      • Most Recent Created Instance: Auto Scaling filters the instances to find the ones that were created most recently from the filtering results in the first step.
    5. Optional:Enable deletion protection for the scaling group.
      After this feature is enabled, the scaling group cannot be deleted from the console or through API operations.
    6. Add tags.
      You can add tags to search for and manage scaling groups. For more information, see Overview.
  5. Specify the scaling configuration.
    1. Select a network type.
      Notice The network type cannot be changed after the scaling group is created.
      Network type Description
      VPC
      • When you create a scaling configuration, you can select only instance types that support VPCs.
      • When you manually add existing ECS instances to the scaling group, you can select only instances that are located in the same VPC as the scaling group.
      Classic Network
      • When you create a scaling configuration, you can select only instance types that support the classic network.
      • When you manually add existing ECS instances to the scaling group, you can select only instances that are located in the classic network.
    2. Optional:If the network type is VPC, configure the required parameters.
      Notice After the scaling group is created, you cannot modify the VPC, multi-zone scaling policy, or instance reclaim mode.
      • VPC
      • VSwitch

        A VSwitch can belong only to one zone. To deploy ECS instances across multiple zones, you must specify multiple VSwitches that belong to different zones. We recommend that you select multiple zones to reduce the risk of insufficient resources and increase the success rate of creating ECS instances.

      • Multi-zone scaling policy
        Policy name Description
        Priority Policy The VSwitch that is first selected has the highest priority. When an ECS instance cannot be created in the zone where the VSwitch with the highest priority resides, Auto Scaling automatically uses the VSwitch that has the second highest priority to create the ECS instance.
        Balanced Distribution Policy The balanced distribution policy takes effect only when the scaling group is associated with multiple VSwitches that are distributed across more than two zones. The policy evenly distributes ECS instances across zones where the VSwitches reside. If the ECS instances are not evenly distributed across zones due to insufficient resources, you can use the Rebalance Distribution feature to evenly distribute the ECS instances. For more information, see Rebalance the distribution of ECS instances.
        Cost Optimization Policy The cost optimization policy takes effect only when you specify multiple instance types in the scaling configuration. Auto Scaling creates ECS instances based on the unit prices of vCPUs in ascending order.

        If you select Preemptible Instance as the billing method in the scaling configuration, preemptible instances are preferentially created. When preemptible instances cannot be created due to insufficient resources, Auto Scaling automatically attempts to create pay-as-you-go instances.

        If you select Cost Optimization Policy, you can set the parameters listed in the following table to enable the scaling policy that involves both pay-as-you-go and preemptible instances.
        Parameter Description
        Minimum Pay-as-you-go Instances The minimum number of pay-as-you-go ECS instances. Default value: 0. If the number of pay-as-you-go ECS instances in the scaling group is less than this value, 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%. The percentage is calculated based on the difference between the total number of instances and the minimum number of pay-as-you-go instances.
        Lowest Cost Instance Types The number of instance types with the lowest cost. Default value: 1. This parameter takes effect when multiple instance types are specified in the scaling configuration. When preemptible instances are created, Auto Scaling evenly creates ECS instances by using the lowest cost instance types.
        Enable Supplemental Preemptible Instances After the Supplemental Preemptible Instances feature is enabled, Auto Scaling automatically creates preemptible instances five minutes before the existing instances are reclaimed.
      • Instance reclaim mode
        Mode Description
        Release Mode When a scale-in event is triggered, Auto Scaling automatically releases a specific number of ECS instances. When a scale-out event is triggered, Auto Scaling automatically creates a specific number of ECS instances for the scaling group.
        Shutdown and Reclaim Mode This mode can improve scaling efficiency.
        When a scale-in event is triggered, the status of the removed ECS instances becomes No Fees for Stopped Instances (VPC-Connected), and their vCPUs, memory, and public IP addresses are reclaimed. You are no longer charged for these resources. However, you are still charged for other resources such as disks and Elastic IP addresses (EIPs). For more information, see No Fees for Stopped Instances (VPC-Connected). These stopped ECS instances form a stopped instance pool.
        Note If the ECS instances have public IP addresses before they enter the No Fees for Stopped Instances (VPC-Connected) state, the instances are reassigned public IP addresses when they are restarted, and the addresses may be different from the previous ones.

        When a scale-out event is triggered, the ECS instances in the stopped instance pool preferentially enter the running state. If these instances are still insufficient, Auto Scaling creates more ECS instances.

        When a scale-out event is triggered, the ECS instances in the stopped instance pool may or may not enter the running state. If the ECS instances in the stopped instance pool cannot enter the running state due to insufficient resources, Auto Scaling releases these instances and creates a specific number of ECS instances.

        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 are stopped or released in some cases. For information about status changes of ECS instances with overdue payments, see Overdue payments.
    3. Optional:Add existing instances.
      If you specify the expected number of instances and then add existing instances, the expected number of instances automatically increases. For example, when you create a scaling group, you set the expected number of instances to one and then add two existing instances. After the scaling group is created, two existing instances are added to the scaling group, and the expected number of instances becomes three.
      You can enable the scaling group to manage the instance lifecycle.
      • If you select Enable the scaling group to manage the instance lifecycle, Auto Scaling automatically releases the ECS instances that are manually removed from the scaling group or automatically removed due to being unhealthy.
      • If you do not select Enable the scaling group to manage the instance lifecycle, the ECS instances that are removed from the scaling group are not be automatically released.
      Note If the type of the instance template is set to Create from Scratch, this feature is not supported.
  6. Configure advanced settings.
    You can associate only a limited number of SLB and ApsaraDB for RDS instances with a scaling group. For more information, see Limits.
    1. Associate SLB instances.
      After you associate SLB instances with the scaling group, ECS instances that are added to the scaling group are automatically added as SLB backend servers. You can specify a server group for the ECS instances. The following table lists two available server groups.
      Server group Port number Weight Description
      Default server group You can specify the port number when you configure listeners for SLB instances. Default value: 50. You can set the weight to other values in the scaling configuration. The group of ECS instances that are used to receive requests. If the listener is not configured with a VServer group or a primary/secondary server group, requests are forwarded to the ECS instances in the default server group.
      VServer group You can specify the port number when you select a VServer group. Default value: 50. You can set the weight to other values when you select a VServer group. If you want to distribute different requests to different backend servers or configure domain name- or URL-based routing methods, you can use VServer groups.

      You can specify only a limited number of VServer groups for a scaling group. For more information, see Limits.

      Note If you specify the default server group and multiple VServer groups at the same time, ECS instances are added to all server groups.
    2. Associate ApsaraDB for RDS instances.
      After the ApsaraDB for RDS instances are specified, the internal IP addresses of ECS instances that are added to the scaling group are added to the whitelists of the ApsaraDB for RDS instances to allow internal communication.
  7. Click Create Scaling Group.
  8. In the Create Scaling Group Status Wizard message, click View Scaling Groups.
    The created scaling group is displayed in the scaling group list. ECS instances can be added to the scaling group only when the scaling group is in the Enabled state.
    • If the type of the instance template is set to Create from Scratch, you must create a scaling configuration or specify an instance launch template to enable the scaling group. For more information, see Create a scaling configuration and Enable a scaling group.
    • If the type of the instance template is set to Select Instance Launch Template or Select Existing Instance, the scaling group enters the Enabled state after it is created.