This topic describes how to create a scaling group. A scaling group is a group of Elastic Compute Service (ECS) instances that are dynamically scaled based on preconfigured rules. You can set the minimum and maximum numbers of ECS instances, the launch templates to create ECS instances, and the policies for removing ECS instances. You can use scaling groups to manage ECS instances based on your business requirements.

Prerequisites

  • Auto Scaling is activated as prompted if you are using it for the first time.
  • If you want to use launch templates to create ECS instances, you must first create a launch template. For more information, see Create a launch template.
  • Before you associate a Classic Load Balancer (CLB, formerly known as Server Load Balancer) instance with a scaling group, make sure that the following requirements are met:
    • You have one or more CLB instances in the Active state. For more information, see Create a CLB instance.
    • The CLB instance and the scaling group reside in the same region.
    • The CLB instance and the scaling group are in the same virtual private cloud (VPC) if their network type is 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 of the VPC type, the ECS instances and the scaling group must be in the same VPC.
    • At least one listener is configured on the CLB instance. For more information, see Listener overview.
    • Health check is enabled for the CLB instance. For more information, see Configure health check.
  • Before you associate an Application Load Balancer (ALB) server group with a scaling group, make sure that the following requirements are met:
    • The network type of the scaling group is virtual private cloud (VPC). The scaling group and the ALB server group to be associated are in the same VPC.
    • The ALB server group is in the Available state.
  • Before you associate an ApsaraDB RDS instance with a scaling group, make sure that the following requirements are met:
    • You have one or more RDS instances in the Running state. For more information, see What is ApsaraDB RDS?
    • The RDS instances and the scaling group reside in the same region.

Background information

You can create only a limited number of scaling groups in a region. To view the quota or request a quota increase, go to the Quota Center.

Procedure

  1. Log on to the Auto Scaling console.
  2. In the left-side navigation pane, click Scaling Groups.
  3. In the top navigation bar, select a region.
  4. In the upper-left corner of the Scaling Groups page, click Create.
  5. Configure parameters for the scaling group and click OK.
    The following table describes the parameters used to create a scaling group.
    Parameter Network type Description
    Scaling Group Name VPC and classic network A scaling group name 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.
    Instance Configuration Source VPC and classic network Valid values:
    • Launch Templates: You can use the instance configuration in the launch template for scale-out.
    • Select Existing Instance: You can extract the configuration of an existing ECS instance to create a configuration template. The default scaling configuration in the template is used to automatically create ECS instances. The extracted configuration includes the instance type, base image, network type, security group, logon password, and tag.
    • Create from Scratch: You can create a scaling group without specifying a launch template. After a scaling group is created, the group is in the Disabled state. You must create a scaling configuration or specify a launch template to create ECS instances before you enable the scaling group.
    Note When you create a scaling group based on ECS instances in the ECS console, the configuration sources and network types of the instances are automatically completed. We recommend that you retain the default settings.
    Different Instance Configuration Source values require different configurations. Perform the following operations based on the values of Instance Configuration Source:
    • If Instance Configuration Source is set to Launch Templates, select an existing launch template and specify the template version. You can also configure Extend Configurations of Launch Template to select multiple instance types and set weights for these instance types. For information about weights, see Use performance metrics to measure Auto Scaling.
    • If Instance Configuration Source is set to Select Existing Instance, select an existing ECS instance.
    Tag VPC and classic network You can add tags to search for and manage scaling groups. For more information, see Overview.
    Note The tags that you added apply only to the scaling group. If you want to add tags to an ECS instance in the scaling group, you must specify the tags in the scaling configuration or in the launch template.
    Instance Removing Policy VPC and classic network You can remove ECS instances from a scaling group based on the instance removing policy. If multiple ECS instances meet the conditions of the policy, one instance is removed at random.
    The Instance Removing Policy parameter contains the Filter First and Then Remove from Results fields. Values of the two fields must be different. Valid values:
    • Earliest Instance Created Using Scaling Configuration: Auto Scaling removes instances that are created by using the earliest scaling configuration and launch template. Manually added instances are not associated with scaling configurations and launch templates. Therefore, manually added instances are not removed first. If all instances that are associated with the earliest scaling configuration and launch template are removed, and the scaling group needs to remove more instances, the manually added instances are removed at random.
      Note Scaling Configuration in Earliest Instance Created Using Scaling Configuration indicates the instance configuration source, which 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, but you replace the template with the lt-foress V1 template later to modify the scaling group. The scaling group considers the lt-foress V2 launch template as the earliest template.

    • Earliest Created Instance: Auto Scaling removes the earliest instances.
    • Most Recent Created Instance: Auto Scaling removes the latest instances.
    • No Policy: This field is available only for Then Remove from Results. No Policy indicates that Auto Scaling does not remove instances based on the Then Remove from Results field.
    If Auto Scaling removes instances based on the Earliest Instance Created Using Scaling Configuration field, you can select one of the following values for the Then Remove from Results field:
    • No Policy: Auto Scaling does not remove instances based on the Then Remove from Results field.
    • Earliest Created Instance: Auto Scaling filters the instances obtained based on the Filter First field to find the earliest instances.
    • Most Recent Created Instance: Auto Scaling filters the instances obtained based on the Filter First field to find the latest instances.
    Note The Scaling Policy field of the scaling group affects how ECS instances are removed from scaling groups. For more information, see Configure a combination policy for removing instances.
    Suspended Processes VPC and classic network You can suspend processes before you perform some operations. For example, you must suspend the health check process before you stop an ECS instance. In this case, 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: Auto Scaling rejects all scale-out requests.
    • Scale-in: Auto Scaling rejects all scale-in requests.
    • Health Check: Auto Scaling suspends the health check and does not remove unhealthy ECS instances.
    • Scheduled Task: When the execution time of a scheduled task is reached, 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 a scaling process and Resume a scaling process.

    Enable Deletion Protection for Scaling Group VPC and classic network After this feature is enabled, the scaling group cannot be deleted in the Auto Scaling console or by calling API operations.
    Health Check for Instances VPC and classic network After this feature is enabled, Auto Scaling checks the status of ECS instances on a regular basis. If an ECS instance is not in the Running state, the instance is considered to be unhealthy and is removed from the scaling group. For more information, see ECS instance lifecycle.
    Minimum Number of Instances VPC and classic network When the number of ECS instances in a scaling group is less than the minimum number of instances, Auto Scaling automatically adds instances until the scaling group reaches the minimum number of instances.
    Maximum Number of Instances VPC and classic network When the number of existing ECS instances in a scaling group is greater than the maximum number of instances, Auto Scaling automatically removes ECS instances until the scaling group reaches the maximum number of instances.
    Expected Number of Instances VPC and classic network You can enter the expected number of instances to enable this feature. Auto Scaling automatically retains the number of ECS instances at the expected value. For more information, see Expected number of instances.
    Note The Expected Number of Instances feature can be enabled only when you create a scaling group. You cannot enable this feature by modifying the number of instances in an existing scaling group.
    Default Cooldown Time (Seconds) VPC and classic network This parameter specifies the default cooldown time of a scaling group in seconds. During the cooldown time, Auto Scaling rejects all scaling activity requests triggered by event-triggered tasks. However, scaling activities triggered by other types of tasks such as scheduled tasks and manually executed tasks are not subject to the cooldown time but can be immediately executed.
    Network Type VPC and classic network You can specify the Multi-zone Scaling Policy and Instance Reclaim Mode parameters only for scaling groups in VPCs. The instances to be added to a scaling group and the scaling group must have the same network type.
    Note When you create a scaling group based on ECS instances in the ECS console, the configuration sources and network types of the instances are automatically completed. We recommend that you retain the default settings.
    • VPC
      • When you create a scaling configuration, you can select only the instance types that support VPCs.
      • When you manually add existing ECS instances to the scaling group, you can select only the instances that are located in the same VPC as the scaling group.
    • Classic Network
      • When you create a scaling configuration, you can select only the instance types that support the classic network.
      • When you manually add existing ECS instances to the scaling group, you can select only the instances that are located in the classic network.
    Note The network type of a scaling group cannot be changed after the scaling group is created.
    Scaling Policy VPC You can specify one of the following scaling policies for a scaling group of the VPC type:
    • Priority Policy: Instances are preferentially created in the zone where the vSwitch with the highest priority resides. Auto Scaling preferentially attempts to scale ECS instances in the zone where the vSwitch with the highest priority resides. If the scaling fails, Auto Scaling attempts to scale instances in the zone where the vSwitch with the next highest priority resides.
    • Balanced Distribution Policy: The balanced distribution policy is valid 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 the zones where the vSwitches reside. If 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: This policy is valid when you specify multiple instance types in the scaling configuration. When a scale-out activity is triggered, Auto Scaling attempts to create ECS instances whose vCPU prices are the lowest. When a scale-in activity is triggered, Auto Scaling attempts to remove ECS instances whose vCPU prices are the highest. If you select Preemptible Instance as the billing method in the scaling configuration, preemptible instances are preferentially created. If 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 continue to configure the following parameters:

    • 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 you set, 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 is valid 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 5 minutes before the existing instances are reclaimed.
    Instance Reclaim Mode VPC When a scale-in activity is triggered, you can specify one of the instance reclaim modes for ECS instances in a scaling group of the VPC type:
    • Release Mode: ECS instances that are removed from the scaling group are released. Resources of these ECS instances are not retained. When a scale-out activity is triggered, Auto Scaling creates ECS instances and adds them to the scaling group.
    • Stop and Reclaim Mode: ECS instances that are removed from the scaling group are stopped and enter the Economical Mode state. Some resources of these ECS instances are retained, and you are charged for these resources. When a scale-out activity is triggered, Auto Scaling preferentially adds the stopped ECS instances to the scaling group. If the number of stopped ECS instances is insufficient to meet the scale-out demand, Auto Scaling creates more ECS instances. This mode makes scaling more efficient.
      Notice
      • Your data stored in ECS instances may be lost when the instances are reclaimed. To avoid data loss, clear application data or logs in ECS instances.
      • Stopped ECS instances may be released due to the following reasons:
        • If the number of ECS instances (including the Stopped state) in a scaling group is greater than the maximum number of instances in the scaling group after you manually reduce the maximum number, Auto Scaling preferentially releases the stopped ECS instances.
        • If stopped ECS instances fail to be added to a scaling group due to insufficient resources or overdue payments, the ECS instances are released.
      • Economical Mode can be enabled only when pay-as-you-go instances are stopped and reclaimed. For more information, see the "Prerequisites", "Application resources", and "Trigger effects" sections in No Fees for Stopped Instances (VPC-Connected).
    VPC VPC Select an existing VPC.
    Note When you create a scaling group based on ECS instances in the ECS console, the configuration sources and network types of the instances are automatically completed. We recommend that you retain the default settings.
    Select VSwitch VPC You must select a vSwitch after you select a VPC. Each vSwitch resides in an individual zone. To deploy ECS instances across multiple zones, you must specify multiple vSwitches in different zones. We recommend that you select multiple zones to reduce the risk that instances fail to be created due to insufficient resources and increase the success rate of scaling out ECS instances.
    Note When you create a scaling group based on ECS instances in the ECS console, the configuration sources and network types of the instances are automatically completed. We recommend that you retain the default settings.
    Add Existing Instance VPC and classic network If Instance Configuration Source is set to Launch Templates or Select Existing Instance, you can add existing ECS instances to a scaling group when you create the scaling group.

    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 in the scaling group 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 select Enable the scaling group to manage the instance lifecycle.
    • If a scaling group manages the lifecycle of ECS instances, the instances are automatically released when they are manually removed from the scaling group or considered unhealthy.
    • If a scaling group does not manage the lifecycle of ECS instances, the instances are not released automatically when they are removed from the scaling group.
    Note Subscription instances can be added to a scaling group, but their lifecycle cannot be managed by the scaling group.
    Associate CLB (Formerly Known as SLB) Instance VPC and classic network After a CLB instance is associated with a scaling group, ECS instances that are added to the scaling group are automatically added as backend servers of the CLB instance. The CLB instance then distributes requests to the ECS instances.

    You can specify a server group to which ECS instances are added. ECS instances can be added to the following types of server groups:

    • Default server group: the group of ECS instances that are used to receive requests. If a 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: 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.

    If you specify the default server group and multiple vServer groups at the same time, ECS instances are added to all the 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 for a quota increase, go to the Quota Center.
    Associated ALB Server Group VPC After an ALB server group is associated with a scaling group, ECS instances that are added to the scaling group are automatically added as backend servers of the ALB server group to process access requests distributed by the ALB instance. You must also specify the port number and weight of a backend server. The default weight is 50. The higher the weight of an ECS instance is, the more access requests are distributed to the instance. If the weight is set to 0, requests are not distributed to the ECS instance.

    If you associate multiple ALB server groups with a scaling group, ECS instances that are added to the scaling group are added to these server groups at the same time.

    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 RDS Instance VPC and classic network After you associate an RDS instance with a scaling group, the internal IP addresses of ECS instances that are added to the scaling group are automatically added to the whitelist of the RDS instance to allow internal communication.
    Note You can associate only a limited number of RDS instances with a scaling group. To view the quota or request a quota increase, go to the Quota Center.
    Set Notification Receiving VPC and classic network When a scaling activity succeeds, fails, or is rejected, Auto Scaling can send you notifications by SMS, internal message, or email. For more information, see Set notification receiving.
  6. In the Create Scaling Group dialog box, click OK.
    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. For more information, see Enable a scaling group.
    Note If Instance Configuration Source is set to Create from Scratch, you must create a scaling configuration or specify a launch template before you enable a scaling group. For more information, see Create a scaling configuration.