Use performance metrics as capacity units

Updated at:
Copy as MD

Assign a weight to each instance type based on a performance metric such as vCPU count. The weight defines the capacity that a single instance of that type contributes to the scaling group, so the group's capacity is measured in performance units rather than instance count.

Background information

By default, Auto Scaling measures scaling group capacity by instance count. This works well when a scaling configuration specifies a single instance type, because instance count is directly proportional to overall performance. However, when the configuration includes a mix of instance types, instance count no longer reflects total computing power. For example, 10 ecs.c5.large (2 vCPUs, 4 GiB) instances provide half the performance of 10 ecs.c5.xlarge (4 vCPUs, 8 GiB) instances.

To address this, assign a weight to each instance type. This lets you accurately measure scaling group performance even when the group contains different instance types. For example, if you set each weight to the instance type's vCPU count, the total capacity represents the total number of vCPUs across all instances.

Key concepts

Concept API parameter Description
weight WeightedCapacity The capacity that an instance type contributes to the scaling group, based on a performance metric such as its vCPU count.
total capacity TotalCapacity The sum of the capacity units of all instances in the scaling group.
maximum capacity MaxSize The maximum value for the total capacity of the scaling group.
Note After a scale-out event, the total capacity might slightly exceed the maximum capacity if the maximum capacity is not evenly divisible by the instance weight. The excess amount will be less than the largest weight in the group.
minimum capacity MinSize The minimum value for the total capacity of the scaling group.
desired capacity DesiredCapacity The target value for the total capacity of the scaling group. Auto Scaling ensures that the total capacity does not fall below this value.
Note After a scale-out event, the total capacity might slightly exceed the desired capacity if the desired capacity is not evenly divisible by the instance weight. The excess amount will be less than the largest weight in the group.

Scaling rules

  • A scale-out event is triggered when the total capacity is less than the desired capacity or the minimum capacity.
  • A scale-in event is triggered when the total capacity is greater than or equal to the sum of the desired capacity and the largest weight.
Note Auto Scaling prioritizes scaling activities based on the group's scaling policy. For example, if you select the Cost Optimization Policy, the system launches instances from types with the lowest weighted unit price and terminates instances from types with the highest weighted unit price. For information about how the weighted unit price is calculated, see How the weighted unit price is calculated.

Usage notes

  • You must set a weight for every instance type in the scaling group.
  • If you remove an instance type from the scaling configuration, the weight of existing instances of that type within the scaling group remains unchanged.
  • When you modify the weight of an instance type with existing instances, Auto Scaling immediately recalculates the group's current capacity. This may trigger a new scaling activity.

Procedure

Use this procedure to set instance type weights when a scaling configuration is the configuration source for the scaling group.

Note You can also use a launch template as the configuration source. To set weights for each instance type, call the CreateScalingGroup API operation and specify the LaunchTemplateOverride.N.InstanceType and LaunchTemplateOverride.N.WeightedCapacity parameters. For more information, see CreateScalingGroup.
  1. Create a scaling group.
    This step focuses on options related to the multi-zone scaling policy. For other scaling group options, see Configure a scaling group.
    1. Set VPC to VPC and then select multiple vSwitches within that VPC.
      Each vSwitch belongs to a single zone. Selecting multiple vSwitches lets you create ECS instances across zones to make better use of available resources.
    2. Set the Cost Optimization Policy policy to Cost Optimized.
    3. Configure the remaining scaling group options as needed.
  2. Create a scaling configuration.
    This step focuses on setting the instance type weight based on vCPU count. For other scaling configuration options, see Create a scaling configuration for ECS instances.
    1. Set the Pay-as-you-go to pay-as-you-go.
    2. Select multiple instance types, up to a maximum of 10.
    3. Select Set vCPU Capacity. The system automatically sets a weight for each selected instance type based on its vCPU count.
      For example, for the selected instance types ecs.c5.large (2 vCPUs, 4 GiB), ecs.c5.xlarge (4 vCPUs, 8 GiB), and ecs.c5.2xlarge (8 vCPUs, 16 GiB), the weights are automatically set to 2, 4, and 8, respectively.

      You can also customize the weights. When you customize weights, follow these recommendations:

      • Use a performance metric that is relevant to your workload, such as the number of vCPUs or the amount of memory in GiB. You can use a single vCPU, 1 GiB of memory, or your least powerful instance type as one capacity unit. The capacity of the scaling group is then calculated relative to this unit.
      • Set appropriate weight values. Ensure that the current capacity of the scaling group is two to three times the largest weight defined for an instance type.
      • Avoid setting vastly different weights for different instance types. For example, do not set the weight of a small instance type to 1 and a large instance type to 200. A large gap between weights can negatively affect the cost-effectiveness of the scaling group.

      For information about the priority of multiple instance types when instances are created, see How the weighted unit price is calculated.

    4. Configure the remaining scaling configuration options as needed.
  3. Enable the scaling group.
  4. Create a scaling rule.
    This step describes the options required for a simple validation test. For other scaling rule options, see Configure scaling rules.
    1. Set the Simple Scaling Rule to Simple Scaling Rule.
    2. Set the Action to Add 10 capacity units.
    3. Configure the remaining scaling rule options as needed.
  5. Execute the scaling rule.
    In this example, the ecs.c5.2xlarge instance type has the lowest weighted unit price. Therefore, the scaling group launches two ecs.c5.2xlarge instances, adding 16 capacity units to the scaling group.

Weighted unit price calculation

If your scaling group uses the Cost Optimization Policy and you have set instance weights, Auto Scaling launches the instance types with the lowest weighted unit price during scale-out. For more information, see Reduce costs by using a scaling policy and multiple instance types.

The following table shows how the weighted unit price is calculated for different instance types.
Note The market prices in this table are for illustration only. For the latest pricing, see the page.ECS Pricing page.
Instance type vCPU Market price Weight Weighted unit price
ecs.c5.large 2 USD 0.18/hour 2 USD 0.090/hour
ecs.c5.xlarge 4 USD 0.34/hour 4 USD 0.085/hour
ecs.c5.2xlarge 8 USD 0.64/hour 8 USD 0.080/hour