liveBook · Manning

Step scaling

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

A step-scaling policy changes capacity by a configured adjustment when a CloudWatch alarm breaches a defined threshold range.

Step scaling adjusts an Auto Scaling group’s desired capacity when a CloudWatch alarm detects that a metric has crossed a threshold. Unlike target tracking, it supports different capacity adjustments for different degrees of threshold breach. section 17.2.2

A step-scaling setup connects these components:

  • A metric records workload, such as EC2 CPU usage or the approximate number of visible SQS messages. section 17.2.2 section 17.3.2
  • A CloudWatch alarm evaluates the metric over configured periods and invokes a scaling policy when its comparison condition is met. section 17.2.2 section 17.3.2
  • A step-scaling policy applies a capacity change, such as adding one EC2 instance; additional steps can provide finer-grained responses. section 17.2.2 section 17.3.2
  • A second alarm and policy can reverse the action when demand falls, such as scaling down when a queue becomes empty. section 17.3.2

URL-to-image workers

An asynchronous URL2PNG application measures SQS queue length. A high-queue alarm invokes a step-scaling policy that adds one instance, while a low-queue alarm removes capacity after processing finishes. A load test generates 250 messages so the alarm, instance launch, and later scale-down can be observed. section 17.3.2

Figure 17.4 Triggering autoscaling based on a CloudWatch metric and alarm

Trace the flow from EC2 or other service metrics through a CloudWatch alarm to an Auto Scaling capacity change. section 17.2.2

Listing 17.8 A step-scaling policy adding one more instance to an Auto Scaling group
# [...]
ScalingUpPolicy:
  Type: 'AWS::AutoScaling::ScalingPolicy'           #1
  Properties:
    AdjustmentType: 'ChangeInCapacity'              #2
    AutoScalingGroupName: !Ref AutoScalingGroup     #3
    PolicyType: 'StepScaling'                       #4
    MetricAggregationType: 'Average'                #5
    EstimatedInstanceWarmup: 60                     #6
    StepAdjustments:                                #7
    - MetricIntervalLowerBound: 0                   #8
      ScalingAdjustment: 1                          #9
# [...]

Inspect a CloudFormation step-scaling policy using ChangeInCapacity, instance warmup, and a step adjustment of one instance. section 17.3.2

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

How deep it goes
Explains metrics, alarm conditions, policy steps, warmup, and scale-down behavior through CloudFormation examples.
Examples
Uses CPU and SQS queue metrics, a URL2PNG worker pool, CloudFormation listings, and a 250-message load test.
What it assumes
Assumes AWS service concepts while defining CloudWatch metrics, alarms, Auto Scaling policies, and queue-driven workload signals.
What you can do after
Operate/configure step scaling with CloudFormation and verify alarms, instance launches, and scale-down events in AWS consoles.
How it connects
Connects CloudWatch, EC2 Auto Scaling, Amazon SQS, CloudFormation, target tracking, predictive scaling, and simple 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.