All Products
Search
Document Center

Auto Scaling:Create a multi-instance type scaling group by using a launch template

Last Updated:Jun 28, 2024

To improve the success rate of scale-out events, you can enable the Extend Launch Template feature when you create a scaling group. This feature allows you to specify multiple instance types at the same time for the scaling group. In this case, you can create a multi-instance type scaling group by using a launch template. This topic describes how to create a multi-instance type scaling group by using a launch template as the instance configuration source.

Background information

A launch template contains configuration information for Elastic Compute Service (ECS) instances, which enables efficient creation of ECS instances. The launch template eliminates the need for repetitive configurations and simplifies the process of creating ECS instances. For more information, see Overview.

When you create an ECS scaling group, you can specify a launch template as the instance configuration source. If scale-out events occur in the scaling group, Auto Scaling creates ECS instances based on the launch template. By default, a launch template contains only one instance type. When Auto Scaling creates ECS instances based on a launch template, the issue of insufficient resources may occur because the template contains only one instance type. To improve the success rate of scale-out events, you can enable the Extend Launch Template feature for your scaling group. This feature allows you to specify multiple instance type at the same time. In this case, if one of the specified instance type has insufficient inventory, Auto Scaling uses another instance type that has sufficient inventory during scale-out events. This prevents disruptions to your business due to scale-out failures.

image

Preparations

Before you create or configure a scaling group, you must create a launch template on the Launch Templates page in the ECS console. You can also select an existing launch template when you create or configure a scaling group. For more information about how to create a launch template, see Create a launch template.

Important

When you create a launch template, you can set the Billing Method parameter only to Pay-as-you-go or Preemptible Instance. Subscription launch templates are not supported. If you specify the Subscription billing method, the system automatically switches to Pay-as-you-go.

In this topic, the following sample configurations are used:

  • Billing Method: Pay-as-you-go

  • Instance Type: ecs.g5.large

启动模板.png

Procedure

In this section, two scaling groups are created to show the effect of Launch template + Multiple instance types.

  • Scaling Group A: Only a launch template is used.

  • Scaling Group B: A launch template and the Extend Launch Template feature are combined to specify multiple instance types.

  1. Log on to the Auto Scaling console.

  2. Create Scaling Group A.

    1. On the Scaling Groups page, click Create.

    2. Configure parameters to complete the group creation and click Create.

      The following table describes the parameter settings used in this example. Any parameters not covered in the following table default to their default settings. For more information, see Manage scaling groups.

      Parameter

      Example

      Description

      Scaling Group Name

      test-a

      Enter a name for the scaling group. The name must meet the format requirements displayed on the UI.

      Type

      ECS

      Select ECS. This value specifies that the scaling group contains ECS instances.

      Instance Configuration Source

      Launch Templates

      Select Launch Templates. This value specifies that Auto Scaling creates ECS instances based on the specified launch template during scale-out events.

      Select Launch Template

      test

      Select the prepared launch template.

      Select Template Version

      Latest Version

      Specify the launch template version that you want to use.

      Minimum Number of Instances

      1

      Specify the minimum instance limit. If the number of instances in the scaling group is less than the value of this parameter, Auto Scaling adds ECS instances to the scaling group until the number of ECS instances in the scaling group reaches the minimum limit.

      Maximum Number of Instances

      1

      Specify the maximum instance limit. If the number of instances in the scaling group is greater than the value of this parameter, Auto Scaling removes ECS instances from the scaling group until the number of ECS instances in the scaling group does not exceed the maximum limit.

  3. Create Scaling Group B.

    Repeat the preceding steps to create Scaling Group B (test-b). In addition to the configurations of Scaling Group A, you must also enable the Extend Launch Template feature for Scaling Group B.

    扩展启动模板.png

    1. In the Extend Launch Template section, select Override Instance Type in Launch Template.

    2. Specify whether to select Use vCPUs to calculate the capacity of the scaling group based on your business requirements.

      If you select Use vCPUs to calculate the capacity of the scaling group, you can view the Weight value of the specified instance type in the Selected Instance Types section. If you reset the number of vCPUs, Auto Scaling recalculates the capacity of your scaling group based on the new number of vCPUs. This may trigger a scaling event. In addition, you can use other instance performance metrics, such as the memory size, to create custom methods for calculating the capacity of your scaling group. For more information, see Use performance metrics to measure Auto Scaling.

    3. In the Available Instance Types section, click the icon icon in front of the instance types that you want to select.

      By default, the instance type of the launch template is added to the Selected Instance Types section. You can select Select All Instance Types, Recommended by Instance Type, or Recommended by vCPU to specify multiple instance types.

      In this example, the extended instance types are ecs.g5ne.large and ecs.g6.large. To mitigate the risk of insufficient resources, we recommend that you specify multiple instance types.

    4. In the Selected Instance Types section, sort the instance types based on your business requirements.

  4. Enable Scaling Group A and Scaling Group B and trigger scale-out events.

    To trigger scale-out events in a scaling group, you can use methods such as configuring a minimum number of instances, configuring an expected number of instances, and executing scaling rules.

    In this example, the Minimum Number of Instances parameter of both scaling groups is set to 1. After you enable the scaling groups, Auto Scaling automatically creates one ECS instance in each scaling group.

Compare the effects

Clicking on the ID of each scaling group will take you to the scaling group details page. On the Instances tab, you can review the ECS instance information and compare the differences in the instance types.

  • Scaling Group A: Only a launch template is used.

    The ecs.g5.large instance type is specified in the launch template. Therefore, the instance type of the automatically created ECS instance is ecs.g5.large. If the ecs.g5.large instance type does not have sufficient inventory, the ECS instance cannot be created.

    伸缩组A.png

  • Scaling Group B: A launch template and the Extend Launch Template feature are combined to specify multiple instance types.

    In addition to the ecs.g5.large instance type of the launch template, the ecs.g5ne.large and ecs.g6.large instance types are extended. In this example, the ecs.g6.large instance type has the highest priority. Therefore, the instance type of the automatically created ECS instance is ecs.g6.large. If the ecs.g6.large instance type has insufficient inventory, Auto Scaling creates an ECS instance of the ecs.g5.large or ecs.g5ne.large instance type.

    伸缩组B.png

Compared with Scaling Group A, Scaling Group B is more flexible and adaptive to actual business scenarios in terms of instance scaling and scale-out success. This superiority is due to the combination of a launch template and multiple instance types. After you specify multiple instance types, Auto Scaling automatically uses another instance type that has sufficient inventory to create ECS instances if one of the instance types does not have sufficient inventory.