SkillSprout
Chapter 8 · Lesson 1
Advanced
6 min read

Scaling Metrics and Auto Scaling Across AWS Services

Overview

Scalability means capacity follows demand without human intervention. The hard part is not turning scaling on; it is choosing a metric that reflects load, a policy that reacts at the right speed, and limits that protect downstream systems. A CPU target on a queue worker, for example, is the wrong signal: the queue depth per instance is the right one.

Think of a supermarket. Opening more tills when the queue gets long (target tracking on queue length) works better than opening tills when the manager feels warm (CPU), and a holiday schedule (scheduled or predictive scaling) staffs up before the rush instead of after it.

DOP-C02 task statements 3.2 and 4.3 ask you to configure auto scaling for EC2 Auto Scaling groups, DynamoDB, RDS storage, ECS capacity providers and EKS autoscalers, and to diagnose scaling problems.

Key Concepts

  • Target tracking keeps a metric near a target value (for example average CPU 50% or ALBRequestCountPerTarget); it creates and manages the CloudWatch alarms for you.
  • Step scaling adds or removes capacity in steps according to alarm breach size; simple scaling waits for a cooldown; scheduled actions handle known events.
  • Predictive scaling uses machine learning on up to 14 days of history to forecast load and pre-provision EC2 capacity; combine it with dynamic policies.
  • Application Auto Scaling is the common API for DynamoDB tables and indexes, ECS services, Aurora replicas, Lambda provisioned concurrency, SageMaker endpoints and more.
  • DynamoDB supports provisioned capacity with auto scaling (target utilisation) or on-demand mode that scales instantly to previously reached peaks and beyond.
  • RDS storage autoscaling grows allocated storage automatically when free space is low (up to a maximum threshold you set); compute is scaled manually or by Aurora replica autoscaling.
  • ECS capacity providers link a service to an ASG (managed scaling targets a utilisation percentage) or to Fargate/Fargate Spot; services scale tasks with target tracking.
  • EKS scales pods with the Horizontal Pod Autoscaler, nodes with Cluster Autoscaler or Karpenter, and can use KEDA for event-driven scaling.

Detailed Notes

Pick the right scaling metric

WorkloadGood metricPoor metric
Web tier behind ALBALBRequestCountPerTarget, average CPUNetwork in (varies by payload)
Queue consumersBacklog per instance = ApproximateNumberOfMessagesVisible / running capacityCPU of workers
Memory-bound Java serviceCustom memory metric from the CloudWatch agentCPU
Lambda concurrencyProvisioned concurrency utilisationInvocations
DynamoDB provisionedConsumed capacity utilisation (target 70%)Table size
ECS serviceECSServiceAverageCPUUtilization, ALBRequestCountPerTarget, custom queue depthCluster CPU only

EC2 Auto Scaling policy comparison

PolicyReactionBest for
Target trackingContinuous, proportionalMost steady workloads
Step scalingBigger breach, bigger stepSpiky workloads with known thresholds
ScheduledTime basedKnown events, business hours
PredictiveForecast, pre-warmsCyclical daily/weekly demand
Warm poolsPre-initialised stopped or hibernated instancesLong boot times

Set instance warm-up so new instances are not counted until ready, use scale-in protection for jobs in progress, add lifecycle hooks to drain or configure, and use mixed instances policies with Spot for cost.

bash
aws autoscaling put-scaling-policy --auto-scaling-group-name web-asg \
  --policy-name req-per-target --policy-type TargetTrackingScaling \
  --target-tracking-configuration '{
    "PredefinedMetricSpecification": {
      "PredefinedMetricType": "ALBRequestCountPerTarget",
      "ResourceLabel": "app/web-alb/50dc6c495c0c9188/targetgroup/web-tg/943f017f100becff"
    },
    "TargetValue": 1000
  }'

Application Auto Scaling for DynamoDB and ECS

bash
aws application-autoscaling register-scalable-target --service-namespace dynamodb \
  --resource-id table/Orders --scalable-dimension dynamodb:table:WriteCapacityUnits \
  --min-capacity 50 --max-capacity 2000
aws application-autoscaling put-scaling-policy --service-namespace dynamodb \
  --resource-id table/Orders --scalable-dimension dynamodb:table:WriteCapacityUnits \
  --policy-name wcu-target --policy-type TargetTrackingScaling \
  --target-tracking-scaling-policy-configuration '{
    "TargetValue": 70.0,
    "PredefinedMetricSpecification": {"PredefinedMetricType": "DynamoDBWriteCapacityUtilization"}
  }'

Remember to scale global secondary indexes as well, or the index becomes the throttle. On-demand tables suit unpredictable traffic; provisioned with auto scaling is cheaper for steady load but reacts in minutes, so sudden bursts can throttle.

Storage and database scaling

  • RDS/Aurora storage: enable storage autoscaling with a maximum threshold; it triggers when free space is below 10% for five minutes and 6 hours since the last modification. Aurora storage grows automatically up to 128 TiB.
  • Aurora replicas: Application Auto Scaling target tracking on average CPU or connections of readers; Aurora Serverless v2 scales ACUs in fine increments without connections dropping.
  • Read scaling: replicas and caches; write scaling needs sharding, DynamoDB or Aurora limitless-style patterns.

Containers

PlatformPod/task scalingNode/capacity scaling
ECS on FargateService target trackingNone to manage; Fargate Spot for cost
ECS on EC2Service target trackingCapacity provider with managed scaling and managed termination protection
EKSHPA (CPU, memory, custom metrics), KEDACluster Autoscaler (node groups) or Karpenter (just-in-time right-sized nodes)

Diagnosing scaling problems

  1. Not scaling out: alarm in INSUFFICIENT_DATA, max capacity reached, service quota, no capacity for the instance type in the AZ, subnets out of IPs, or launch template errors (look at the ASG activity history).
  2. Flapping: cooldowns or warm-up too short, or a metric that oscillates; widen the scale-in threshold.
  3. Scaling but still failing: downstream database or dependency is the bottleneck; add caching, queues or connection pooling.
  4. Uneven load: ensure cross-zone load balancing and AZ rebalance behaviour, and that scaling uses the correct dimension.

Always set CloudWatch alarms on GroupInServiceInstances, throttling metrics (ThrottledRequests, ProvisionedThroughputExceeded) and scaling failures to detect problems early.

Real World Example

Scenario: an image-processing service reads jobs from SQS and scaled poorly using CPU. Workers are idle while waiting on S3, so CPU stays low while the backlog grows. The team publishes a backlog-per-instance custom metric and uses target tracking to keep it near 10 messages per worker.

The DynamoDB job table uses auto scaling with a 70% target and its index has matching scaling. A scheduled action raises minimum capacity before the daily 08:00 batch, and predictive scaling covers the weekly peak.

Architecture Diagram

Choosing the signal that drives scaling
Architecture
AWS Cloud
SQS queueBacklog metric
CloudWatchCustom metric
Auto ScalingTarget tracking
Workers
DynamoDBApp Auto Scaling

Metrics feed policies that adjust capacity for several services.

  1. 1Messages accumulate in the SQS queue.
  2. 2A metric divides backlog by running instances and is published to CloudWatch.
  3. 3A target tracking policy adjusts the desired capacity of the ASG.
  4. 4New workers consume messages and write results to DynamoDB.
  5. 5Application Auto Scaling adjusts table throughput to match consumption.

Best Practices

  • ✓Scale on a metric that correlates with load, such as request count per target or queue backlog per instance.
  • ✓Prefer target tracking; add scheduled or predictive scaling for known patterns.
  • ✓Configure warm-up, cooldown and lifecycle hooks, and monitor scaling activity failures.
  • ✓Scale dependencies together: GSIs, read replicas, connection pools and downstream quotas.
  • ✓Use capacity providers or Karpenter to scale the nodes behind container workloads automatically.

Common Interview Questions

Exam Tips

DOP-C02 focus

  • "Scale queue consumers" = backlog per instance custom metric, not CPU.
  • "Table throttles at sudden peaks" = on-demand mode or higher minimum capacity; remember GSIs.
  • "ECS on EC2 has no room for tasks" = capacity provider with managed scaling.
  • "Forecast daily cyclical load" = predictive scaling.

Finished this lesson?

0 of 44 lessons done · 0% of the course