Mastering Target Tracking Scaling Policies for Amazon EC2 Auto Scaling


Scaling your EC2 instances to match dynamic workloads can be challenging. Amazon EC2 Auto Scaling simplifies this with target tracking scaling policies, a powerful feature that automatically adjusts capacity to maintain optimal performance and cost efficiency. In this blog, we’ll dive deep into how target tracking works, its benefits, and how to implement it with real-world examples.
What Are Target Tracking Scaling Policies?
Target tracking scaling policies allow you to define a target value for a specific Amazon CloudWatch metric (e.g., CPU utilization, request count per instance). EC2 Auto Scaling then adds or removes instances to keep the metric close to your target. For example:
If your target is 60% CPU utilization, Auto Scaling will launch instances when CPU usage exceeds 60% and terminate them when it drops below.
If your application handles HTTP requests, you could target 500 requests per minute per instance to ensure consistent throughput.
This "set-it-and-forget-it" approach reduces manual intervention and ensures your application scales seamlessly.
Benefits of Target Tracking Scaling
Automatic Scaling: Responds to traffic spikes or drops without manual input.
Cost Optimization: Runs only the instances needed, avoiding over-provisioning.
Simplified Configuration: No need to define complex scaling rules for every scenario.
Integration with CloudWatch: Leverage built-in metrics or custom metrics for granular control.
Proactive Scaling: Adjusts capacity before performance degrades.
How Target Tracking Scaling Works
Select a Metric: Choose a CloudWatch metric (e.g.,
CPUUtilization
,RequestCountPerTarget
).Set a Target Value: Define the ideal average value for the metric.
Auto Scaling Adjusts Capacity: EC2 Auto Scaling uses Amazon’s scaling algorithms to add/remove instances.
While in the creation of Auto-Scaling-Group > Configure Group Size and Scaling Policies (Screenshot Above)
Step-by-Step Implementation
Example 1: Scaling Based on CPU Utilization
Scenario: You want to maintain an average CPU utilization of 40% for your web servers.
Via AWS Console:
Navigate to EC2 Auto Scaling Groups > Select your ASG > Automatic Scaling tab.
Click Create dynamic scaling policy > Target tracking scaling.
Configure:
Policy name:
cpu80-target
Metric type:
Average CPU Utilization
Target value: 80
Click Create.
Screenshot of the metric selection and target value fields.
AWS Documentation Suggested Steps as follows,
To create a target tracking scaling policy for an existing Auto Scaling group
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/, and choose Auto Scaling Groups from the navigation pane.
Select the check box next to your Auto Scaling group.
A split pane opens up in the bottom of the page.
Verify that the scaling limits are appropriately set. For example, if your group's desired capacity is already at its maximum, you need to specify a new maximum in order to scale out. For more information, see Set scaling limits for your Auto Scaling group.
On the Automatic scaling tab, in Dynamic scaling policies, choose Create dynamic scaling policy.
To define a policy, do the following:
For Policy type, keep the default of Target tracking scaling.
Specify a name for the policy.
For Metric type, choose a metric. You can choose only one metric type. To use more than one metric, create multiple policies.
If you chose Application Load Balancer request count per target, choose a target group in Target group.
Specify a Target value for the metric.
(Optional) For Instance warmup, update the instance warmup value as needed.
(Optional) Select Disable scale in to create only a scale-out policy. This allows you to create a separate scale-in policy of a different type if wanted.
Choose Create.
AWS CLI Command to set target-tracking-configuration based of “Average CPU Utilization”
aws autoscaling put-scaling-policy \
--policy-name cpu80-target \
--auto-scaling-group-name my-asg \
--policy-type TargetTrackingScaling \
--target-tracking-configuration '{
"PredefinedMetricSpecification": {
"PredefinedMetricType": "ASGAverageCPUUtilization"
},
"TargetValue": 80.0
}'
I had a Stress test running on my EC2 instances, which gets my EC2 instances CPU utilization over 80%
which can be seen under EC2 > AutoScalingGroup Settings > MyAutoScalingGroup > Monitoring (Screenshot Below)
Click on Activity to see New EC2 Instance getting created due to “Target Tracking CPU Utilization Policy”
Example 2: Scaling Based on Application Load Balancer (ALB) Requests
Scenario: Your application uses an ALB, and you want to maintain 1000 requests per minute per instance.
Via AWS Console:
Follow steps 1–2 above.
Configure:
Metric type:
Application Load Balancer Request Count Per Target
Target value:
1000
ALB Target Group: Select your target group.
AWS CLI command for “Application Load Balancer Request Count Per Target”
aws autoscaling put-scaling-policy \
--policy-name alb-requests-target \
--auto-scaling-group-name my-asg \
--policy-type TargetTrackingScaling \
--target-tracking-configuration '{
"PredefinedMetricSpecification": {
"PredefinedMetricType": "ALBRequestCountPerTarget",
"ResourceLabel": "app/my-alb/1234567890abcdef/targetgroup/my-target-group/abcdef0123456789"
},
"TargetValue": 1000.0
}'
Advanced Tips
Custom Metrics: Use CloudWatch custom metrics (e.g., queue depth, memory usage) for niche workloads.
Cooldown Periods: Configure cooldown timers to prevent rapid scaling fluctuations.
Combination with Other Policies: Pair target tracking with step scaling for complex scenarios.
Troubleshooting issues to consider
Metric Not Found: Ensure the metric is correctly associated with your ASG (e.g., ALB metrics require the ASG to be attached to the target group).
Over-scaling: Adjust the target value or enable instance warm-up to stabilize scaling decisions.
Monitor CloudWatch Alarms: Target tracking creates CloudWatch alarms automatically—check their status in the AWS Console.
Conclusion
Target tracking scaling policies are a game-changer for managing EC2 workloads. By automating capacity adjustments, you save time, reduce costs, and ensure reliable performance. Whether you’re scaling based on CPU, network, or custom metrics, this feature simplifies infrastructure management.
Reference: Explore the official AWS documentation for advanced configurations.
You are now ready to optimize your EC2 fleet !
Implement target tracking, and let AWS handle the heavy lifting!
Thank you for the read. Hope you like it. I appreciate your feedback.
Follow for more Azure and AWS Content. Happy Learning!
Regards,
Jineshkumar Patel
Subscribe to my newsletter
Read articles from Jineshkumar Patel directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Jineshkumar Patel
Jineshkumar Patel
Cloud Enthusiast working as Cloud Infrastructure Consultant. My Hobby is to build and destroy Cloud Projects for Blogs. Love to share my learning journey about DevOps, AWS and Azure. Subscribe and Follow up with "CloudCubes".Thank you and Happy Learning !!