Certopolis

AWS Certified Solutions Architect – Associate

EC2 Auto Scaling policies: target tracking, step, predictive

Target tracking keeps a metric near a target value and is what AWS recommends first. Step scaling adds or removes capacity in steps sized by how far an alarm is breached. Scheduled scaling changes capacity at set times, and predictive scaling forecasts daily and weekly patterns to launch capacity before the load arrives.

Dynamic policies

Target tracking works like a thermostat: you pick a metric, such as ASGAverageCPUUtilization or ALBRequestCountPerTarget, and a target, and Auto Scaling manages the CloudWatch alarms. Choose a metric that falls as capacity grows.

With several target tracking policies, the group scales out if any policy wants to, and scales in only if all policies with scale-in enabled agree. You can disable the scale-in part of a policy. If policies conflict, Auto Scaling picks the one that gives the largest capacity.

Step scaling uses step adjustments that vary with the size of the alarm breach. Simple scaling makes one adjustment and then waits for a cooldown.

Scheduled and predictive

A scheduled action sets desired, minimum or maximum capacity at a time, once or on a cron schedule in a time zone you choose (UTC by default). A group can have up to 125 scheduled actions.

Predictive scaling analyzes history to find daily or weekly patterns and adds capacity ahead of the forecast. AWS suggests it for cyclical traffic, recurring batch patterns and applications that take a long time to initialize. It can be combined with dynamic scaling.

Health checks and warm pools

EC2 status checks are the default health check. Elastic Load Balancing health checks are ignored until you turn them on for the group. A custom health check can mark an instance unhealthy with SetInstanceHealth, and Auto Scaling replaces it.

The health check grace period delays health checks on new instances. It defaults to 300 seconds in the console and 0 with the CLI or SDK.

A warm pool holds pre-initialized instances for applications with long boot times. Instances can wait Stopped, Hibernated or Running. Stopped is cheapest; Hibernated keeps RAM contents on the EBS root volume; Running is discouraged because you pay for the instances. By default the pool size is maximum capacity minus desired capacity.

Where the exam catches people

  • Believing one target tracking policy can block scale-out: any policy can scale out, but scale-in needs every policy with scale-in enabled to agree.
  • Believing ELB health checks replace instances by default: Auto Scaling ignores them until you turn them on for the group.
  • Believing a Stopped warm pool keeps loaded data in memory: only the Hibernated state saves RAM to the EBS root volume.
  • Believing a warm pool fills itself whatever the group size: by default its size is maximum minus desired capacity, so equal values give an empty pool.
  • Believing target tracking works on raw queue depth: AWS lists ApproximateNumberOfMessagesVisible as a metric that doesn't work; use messages per instance.

Written from Amazon Web Services's documentation

Try 3 questions on this

Pick an answer to see why each option is right or wrong.

  1. An Auto Scaling group has two target tracking policies: average CPU utilization at 50% and request count per target at 1,000. In the evening, CPU utilization falls to 15% while request count per target stays near 1,000, and the group never scales in. The company must let the group scale in when CPU utilization is low, and must keep the request count policy's scale-out behavior unchanged. Which solution meets these requirements?

    Right. In the game that’s Renown for your Design Resilient Architectures building.

    Not that one: C is right. In the game your Design Resilient Architectures building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    Disabling scale-in on the request count policy takes it out of that vote, so the CPU policy alone decides scale-in, while the request count policy still scales out.

    Written from docs.aws.amazon.com/autoscaling/ec2/userguide/as-scaling-target-tracking.html

  2. An application spends most of its twenty-minute startup loading a large reference dataset into memory. The team wants a warm pool that removes that startup from a scale-out event, while paying as little as possible for the instances that are waiting. The instances use an Amazon EBS volume as their root device and meet the hibernation prerequisites. Which approach will meet these requirements?

    Right. In the game that’s Renown for your Design Resilient Architectures building.

    Not that one: B is right. In the game your Design Resilient Architectures building would lose a little Renown, and this question would come back later.

  3. An application in an Auto Scaling group behind a load balancer can enter a state where it answers the load balancer's health path correctly while its background queue worker has died. The team must have the group replace instances in that state, and must not let the load balancer's own checks start failing for healthy instances. Which approach will meet these requirements?

    Right. In the game that’s Renown for your Design Resilient Architectures building.

    Not that one: C is right. In the game your Design Resilient Architectures building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    AWS lists "custom health checks that you define" among the notification sources, alongside Amazon EC2, Elastic Load Balancing, VPC Lattice and Amazon EBS, and states the consequence: "When Amazon EC2 Auto Scaling determines that an InService instance is unhealthy, it replaces it with a new instance to maintain the desired capacity of the group." A custom check reports unhealthy directly to the group, so replacement happens without changing what the load balancer measures. Folding the worker into the load balancer's health path couples two decisions - who gets traffic, and who exists - so a transient worker failure also drains the instance.

    Written from docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-health-checks.html