Scale your Amazon ECS service using predefined increments based on CloudWatch alarms
With step scaling policies, you specify CloudWatch alarms that initiate the scaling process.
For example, if you want to scale out when CPU utilization reaches a certain level,
create an alarm using the CPUUtilization
metric provided. When you create a
step scaling policy, you must specify one of the following scaling adjustment types:
-
Add – Increase the number of tasks by a specified number of capacity units or a specified percentage of the current capacity.
-
Remove – Decrease the number of tasks by a specified number of capacity units or a specified percentage of the current capacity.
-
Set to - Set the number of tasks to the specified number of capacity units.
For example, suppose that the target capacity and fulfilled capacity are 10 and the scaling policy adds 1. When the alarm is breached, the automatic scaling process adds 1 to 10 to get 11, so Amazon ECS launches 1 task for the service.
We strongly recommend that you use target tracking scaling policies to scale on metrics like average CPU utilization or average request count per target. Metrics that decrease when capacity increases and increase when capacity decreases can be used to proportionally scale out or in the number of tasks using target tracking. This helps ensure that Service Auto Scaling follows the demand curve for your applications closely.
For an overview of step scaling policies and how they work, see Step scaling policies in the Application Auto Scaling User Guide. After you read this introduction, see the following sections to learn how to configure step scaling for Amazon ECS using the console and Amazon Command Line Interface.
To configure step scaling policies for your Amazon ECS service using the Amazon ECS console
-
In addition to the standard IAM permissions for creating and updating services, you need additional permissions. For more information, see IAM permissions required for Amazon ECS service auto scaling.
-
You can configure a scaling policy when you create or update a service. For more information, see one of the following:
-
Create a service using defined parameters— Create a new service
-
Updating an Amazon ECS service using the console— Update an existing service
-
To configure step scaling policies for your Amazon ECS service using the Amazon CLI
-
In addition to the standard IAM permissions for creating and updating services, you need additional permissions. For more information, see IAM permissions required for Amazon ECS service auto scaling.
-
Register your Amazon ECS service as a scalable target using the register-scalable-target command.
-
Create a scaling policy using the put-scaling-policy command.
-
Create an alarm that initiates the scaling policy using the put-metric-alarm command.