Scale your Amazon ECS service using a target metric value
With target tracking scaling policies, you select a metric and set a target value. Amazon ECS Service Auto Scaling creates and manages the CloudWatch alarms that control the scaling policy and calculates the scaling adjustment based on the metric and the target value. The scaling policy adds or removes service tasks as required to keep the metric at, or close to, the specified target value. In addition to keeping the metric close to the target value, a target tracking scaling policy also adjusts to the fluctuations in the metric due to a fluctuating load pattern and minimizes rapid fluctuations in the number of tasks running in your service.
Considerations
Consider the following when using target tracking policies:
-
A target tracking scaling policy assumes that it should perform scale out when the specified metric is above the target value. You cannot use a target tracking scaling policy to scale out when the specified metric is below the target value.
-
A target tracking scaling policy does not perform scaling when the specified metric has insufficient data. It does not perform scale in because it does not interpret insufficient data as low utilization.
-
You may see gaps between the target value and the actual metric data points. This is because Service Auto Scaling always acts conservatively by rounding up or down when it determines how much capacity to add or remove. This prevents it from adding insufficient capacity or removing too much capacity.
-
To ensure application availability, the service scales out proportionally to the metric as fast as it can, but scales in more gradually.
-
Application Auto Scaling turns off scale-in processes while Amazon ECS deployments are in progress. However, scale-out processes continue to occur, unless suspended, during a deployment. For more information, see Service auto scaling and deployments.
-
You can have multiple target tracking scaling policies for an Amazon ECS service, provided that each of them uses a different metric. The intention of Service Auto Scaling is to always prioritize availability, so its behavior differs depending on whether the target tracking policies are ready for scale out or scale in. It will scale out the service if any of the target tracking policies are ready for scale out, but will scale in only if all of the target tracking policies (with the scale-in portion turned on) are ready to scale in.
-
Do not edit or delete the CloudWatch alarms that Service Auto Scaling manages for a target tracking scaling policy. Service Auto Scaling deletes the alarms automatically when you delete the scaling policy.
-
The
ALBRequestCountPerTarget
metric for target tracking scaling policies is not supported for the blue/green deployment type.
For more information about target tracking scaling policies, see Target tracking scaling policies in the Application Auto Scaling User Guide.
To configure target 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 target scaling policies for your Amazon ECS service using the AWS 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.