Lesson 2 of 3 Amazon EC2 Auto Scaling

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.

PolicyHow it worksUse for
Target trackingKeeps a metric at a target (CPU 50%, ALB requests per target, network, custom); AWS creates the alarms; AWS-recommendedMost workloads
Step scalingDifferent adjustments at different CloudWatch alarm thresholdsGraduated responses to large changes
Simple scalingOne adjustment, then a cooldownLegacy
Scheduled actionsChange minimum, maximum or desired capacity at set timesBusiness hours, known one-off events
Predictive scalingForecasts load from up to 14 days of history and launches capacity ahead; combine with target trackingRecurring daily or weekly patterns
Match the pairs

Scaling policy types

Exam skills 3.2.2 · 4.2.2

Match each requirement with the scaling policy type that suits it.

Log in to try this activity Interactive activities are free with an account.

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.

WorkloadMetric
Web tier behind an ALBALBRequestCountPerTarget, which tracks load more directly than CPU
CPU-bound processingAverage CPU utilisation
Workers processing an SQS queueBacklog 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.

Sort into groups

Which scaling metric?

Exam skills 3.2.2 · 2.2.3

Choose the metric to track for each workload.

Log in to try this activity Interactive activities are free with an account.

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.

Fill in the value

Queue backlog target

Exam skills 3.2.2

Work out the target backlog per instance for a queue.

Log in to try this activity Interactive activities are free with an account.
Worked example

A policy for each pattern

Each scaling policy suits a particular traffic pattern. The following table identifies the appropriate policy for several patterns.

PatternPolicy
Keep average CPU around 50%Target tracking
Traffic always rises at 08:00 on weekdaysScheduled scaling (or predictive scaling)
Workers processing an SQS queueTarget 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 trafficLaunch 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.

Check yourself

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.