liveBook · Manning

Target tracking

As explained in Amazon Web Services in Action, Third Edition: An in-depth guide to AWS

A target-tracking scaling policy automatically adjusts capacity to keep a selected metric near a configured target value.

Target tracking is an EC2 Auto Scaling policy that adjusts the number of instances to keep a chosen metric near a target value. Set the target—for example, 70% average CPU utilization—instead of defining scaling steps and alarm thresholds yourself. The policy creates CloudWatch alarms in the background and changes the Auto Scaling group’s desired capacity as load changes. section 17.2.2 section 17.3.1

Choose a metric that responds proportionally when instances are added or removed:

  • Use average CPU utilization across an Auto Scaling group, requests per Application Load Balancer target, or average network traffic in or out. section 17.3.1
  • Use another CloudWatch metric if instance count affects it proportionally. Request latency does not meet that requirement in this example. section 17.3.1
  • Use a different policy when the metric does not fit. SQS queue length does not correlate with the number of workers processing its messages, so the queue-backed example uses step scaling instead. section 17.3.2

Scale a WordPress instance pool by CPU

Place the web servers in an Auto Scaling group behind an Application Load Balancer. In a CloudFormation scaling policy, set PolicyType to TargetTrackingScaling, choose ASGAverageCPUUtilization as the predefined metric, set TargetValue to 70, and set EstimatedInstanceWarmup to 60. The example group has a minimum of two instances and a maximum of four, so scaling remains within those bounds. section 17.3.1

Listing 17.6 Creating a scalable, HA WordPress setup, part 3
ScalingPolicy:
  Type: 'AWS::AutoScaling::ScalingPolicy'                     #1
  Properties:
    AutoScalingGroupName: !Ref AutoScalingGroup               #2
    PolicyType: TargetTrackingScaling                         #3
    TargetTrackingConfiguration:                              #4
      PredefinedMetricSpecification:                          #5
        PredefinedMetricType: ASGAverageCPUUtilization        #6
      TargetValue: 70                                         #7
    EstimatedInstanceWarmup: 60                               #8

The CloudFormation listing shows the policy properties and the 70% CPU target together. section 17.3.1

How Amazon Web Services in Action, Third Edition: An in-depth guide to AWS covers it

How deep it goes
Defines the policy, lists metric choices, and provides a CloudFormation configuration; leaves alarm creation to the policy.
Examples
Configures a WordPress Auto Scaling group for a 70% average CPU target and contrasts it with an SQS queue-length scenario.
What you can do after
Apply it via CloudFormation to configure CPU-based target tracking and recognize when a metric calls for step scaling instead.
How it connects
Connects CloudWatch metrics and alarms with EC2 Auto Scaling groups, Application Load Balancers, and step scaling.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Amazon Web Services in Action, Third Edition: An in-depth guide to AWS. The section links point to the parts of the book it draws on.