A scaling group is a collection of Elastic Compute Service (ECS) instances or elastic container instances that can be used for similar business scenarios. When you create a scaling group, you can specify the minimum and maximum numbers of instances, templates that are used for scale-out, and policies that are used for scale-in. You can use a scaling group to manage a group of instances based on your business requirements.

Prerequisites

  • You have the required permissions for Auto Scaling. For more information, see Manage the service-linked role for Auto Scaling.
  • If you want to use a launch template to create ECS instances, a launch template is created. For more information, see Create a launch template.
  • The following requirements are met if you want to associate a Classic Load Balancer (CLB) instance with a scaling group:
    • 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 is associated with at least one listener. For more information, see Listener overview.
    • Health check is enabled for the CLB instance. For more information, see Configure health check.
    • The network types of the CLB instance and the scaling group are subject to the following limits:
      • The CLB instance and the scaling group must be 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.
        Note In other cases, no limit is applied to the network type when you associate a scaling group with a CLB instance.
  • 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 is virtual private cloud (VPC). The scaling group and the ALB server group that you want to associate are in the same VPC.
    • The ALB server group is in the Available state.
  • 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 and are in the Running state. For more information, see What is ApsaraDB RDS?.
    • The scaling group and the ApsaraDB RDS instance are 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.
  • When you create a scaling group, you must configure the Minimum Number of Instances and Maximum Number of Instances parameters. You can configure the Expected Number of Instances parameter based on your business requirements.
    • If you set the Minimum Number of Instances parameter to a value greater than 0 and the number of instances in the scaling group for which you do not enable the Expected Number of Instances feature is less than the specified minimum number, Auto Scaling automatically triggers a scale-out activity to reach the minimum number of instances.
    • If you set the Expected Number of Instances parameter to a value greater than 0 and the number of instances in the scaling group is less than the specified expected number, Auto Scaling automatically triggers a scale-out activity to reach the expected number of instances.
    Note Auto Scaling automatically triggers the preceding scale-out activities without the need to execute scaling rules.

Procedure

  1. Log on to the Auto Scaling console.
  2. In the top navigation bar, select a region.
  3. In the left-side navigation pane, click Scaling Groups.
  4. In the upper-left corner of the Scaling Groups page, click Create.
  5. Configure the following parameters for the scaling group and click OK.
    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 Manually update images 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 ECS instance lifecycle in a scaling group.
    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 Set notification receiving.
  6. In the Create Scaling Group dialog box, click OK.
    You can view the scaling group on the Scaling Groups page. The scaling group is in the Disabled state.

What to do next

  1. If you set Instance Configuration Source to Create from Scratch when you create a scaling group, you must create and enable a scaling configuration or specify a launch template. The steps that you must perform to create a scaling configuration vary based on the value of the Type parameter.
  2. Enable the scaling group. For more information, see Enable a scaling group.

    You can only scale instances in scaling groups that are in the Enabled state.