Choosing Auto Scaling Policies and Metrics
This lesson explains how scaling policies decide when an Auto Scaling group adds or removes instances, and how to choose the right one for a traffic pattern.
Learning outcomes
After completing this lesson, you will be able to:
- Distinguish target tracking, step, scheduled and predictive scaling.
- Choose a metric that follows the work.
- Explain how scaling policies interact.
Policy types
EC2 Auto Scaling policies differ in how much they decide for you. A target tracking policy keeps a metric at a chosen value, such as CPU at 50% or a number of ALB requests per target, and creates and manages the CloudWatch alarms itself. AWS recommends it for most workloads because it needs the least tuning. A step scaling policy responds to alarms that you define with different adjustments at different thresholds, such as adding two instances above 70% CPU and five above 90%, for graduated responses to large changes. A simple scaling policy makes one adjustment and then waits for a cooldown before reacting again, which is slow and considered legacy.
Scheduled actions change the minimum, maximum or desired capacity at set times, such as before business hours or a known sales event. Predictive scaling forecasts load from the group's recent history and launches capacity before regular daily or weekly peaks, and is combined with target tracking to handle the unexpected. The following table summarises the policy types.
| Policy | How it works | Use for |
|---|---|---|
| Target tracking | Keeps a metric at a target (CPU 50%, ALB requests per target, network, custom); AWS creates the alarms; AWS-recommended | Most workloads |
| Step scaling | Different adjustments at different CloudWatch alarm thresholds | Graduated responses to large changes |
| Simple scaling | One adjustment, then a cooldown | Legacy |
| Scheduled actions | Change minimum, maximum or desired capacity at set times | Business hours, known one-off events |
| Predictive scaling | Forecasts load from up to 14 days of history and launches capacity ahead; combine with target tracking | Recurring daily or weekly patterns |
Scaling policy types
Choosing a metric
A scaling policy works only as well as the metric it follows, which should rise and fall with the work each instance must do. For a web tier behind an ALB, ALBRequestCountPerTarget measures load directly; CPU may stay low while requests queue, for example when instances wait on a database. For CPU-bound processing, such as video encoding, average CPU utilisation is the right signal.
For workers that process an SQS queue, neither works well, because the amount of work waiting is what matters. The standard approach publishes a custom backlog per instance metric, the number of visible messages divided by the number of running instances, and tracks a target value for it. The following table summarises the choice.
| Workload | Metric |
|---|---|
| Web tier behind an ALB | ALBRequestCountPerTarget, which tracks load more directly than CPU |
| CPU-bound processing | Average CPU utilisation |
| Workers processing an SQS queue | Backlog per instance: visible messages divided by running instances, published as a custom metric |
For a queue, the target backlog is the acceptable latency divided by the time to process one message: if each message takes 2 seconds and messages may wait 100 seconds, the target is 50 messages per instance.
Which scaling metric?
Scaling behaviour
Scaling policies interact according to a few rules. Groups should scale out quickly, to protect performance, and scale in conservatively, to avoid flapping, where capacity is repeatedly added and removed.
When several policies apply at once, the group follows whichever policy gives the largest capacity, so a scheduled action and a target tracking policy can work together without the smaller one removing capacity the larger one needs. The group's minimum and maximum capacity bound every policy: no policy can take the group below the minimum or above the maximum.
Queue backlog target
A policy for each pattern
Each scaling policy suits a particular traffic pattern. The following table identifies the appropriate policy for several patterns.
| Pattern | Policy |
|---|---|
| Keep average CPU around 50% | Target tracking |
| Traffic always rises at 08:00 on weekdays | Scheduled scaling (or predictive scaling) |
| Workers processing an SQS queue | Target tracking on backlog per instance |
| Add 2 instances at 70% CPU and 5 at 90% | Step scaling |
| Install software and register with a licence server before serving traffic | Launch lifecycle hook |
Target tracking is the right default in most questions. Queue-based workers are the classic exception, because CPU does not show how far behind the queue is.
Traffic rises every weekday at 08:00. Which scaling option adds capacity before it arrives?
Show answer
A scheduled action, or predictive scaling, which learns the daily pattern and launches instances ahead of it.
Exam Tips
Remember for the exam
- To keep CPU around a target, use target tracking.
- For a predictable daily peak use predictive scaling; for a one-off event use a scheduled action.
- For workers processing an SQS queue, scale on backlog per instance.
- For a web tier behind an ALB, track request count per target.