AWS Auto Scaling & Performance Architecture — Overview
Auto Scaling questions appear throughout SAP-C02 (30% of Domain 4: Cost & Operations). The exam tests scaling policy selection (step vs target tracking vs predictive), scaling patterns for different services, and performance optimization strategies. This post covers the complete scaling decision framework from EC2 through containers to serverless.
EC2 Auto Scaling Policies — Decision Guide
| Policy Type | How It Works | Best For |
|---|---|---|
| Target Tracking | Maintain a metric at a target value (e.g., CPU at 50%). ASG adds/removes instances automatically. | Most workloads. Simplest. Recommended default. Works like a thermostat. |
| Step Scaling | Different scaling actions at different alarm thresholds (e.g., +1 at 60% CPU, +3 at 80% CPU). | When you need different responses at different severity levels. |
| Simple Scaling | Add/remove fixed number on alarm. Waits for cooldown before next action. | Legacy. Use Target Tracking or Step instead. |
| Predictive Scaling | ML analyzes historical patterns → pre-scales BEFORE demand arrives. | Recurring traffic patterns (daily peaks, weekly cycles). Eliminates warm-up lag. |
| Scheduled Scaling | Set min/max/desired at specific times (cron expressions). | Known events (sales, deployments, business hours only). |
Exam answer: “Simplest scaling” = Target Tracking. “Recurring daily pattern” = Predictive. “Known event next Tuesday” = Scheduled. “Different response per severity” = Step.
Warm Pools & Instance Refresh
- Warm Pools: Pre-initialized instances in a “stopped” or “running” pool. When ASG scales out, instances launch from warm pool (seconds) instead of cold launch (minutes). Use when boot time is long (large AMIs, config downloads).
- Instance Refresh: Rolling replacement of instances (e.g., deploy new AMI). Set minimum healthy percentage (e.g., 90%). ASG terminates old, launches new in batches. Integrated with CloudFormation and CodeDeploy.
- Lifecycle Hooks: Pause instance during launch/terminate for custom actions (install software, drain connections, save logs). Timeout after configurable period.
Scaling Metrics — What to Scale On
| Metric | When to Use | Pitfalls |
|---|---|---|
| CPUUtilization | CPU-bound workloads (computation, rendering) | Not useful for I/O-bound or memory-bound workloads |
| ALBRequestCountPerTarget | Web applications (scales per request load) | Best for even request distribution |
| SQS ApproximateNumberOfMessages | Queue-based processing (workers) | Use backlog-per-instance metric for accuracy |
| Custom Metrics | Application-specific (active connections, GPU utilization) | Requires CloudWatch Agent or custom publishing |
| NetworkIn/Out | Network-bound workloads (streaming, file transfer) | Less common, usually CPU or request count is better proxy |
Performance Optimization Patterns
| Problem | Solution | Service |
|---|---|---|
| Cold start latency (Lambda) | Provisioned Concurrency — pre-warms execution environments | Lambda |
| Slow instance boot (EC2) | Warm Pools — pre-initialized instances ready to serve | EC2 ASG |
| Database connection storms | RDS Proxy — connection pooling + multiplexing | RDS/Aurora |
| Global latency | CloudFront + Global Accelerator + Multi-Region | Networking |
| Read-heavy database | ElastiCache + Read Replicas | Database |
| Uneven traffic distribution | Cross-zone load balancing + proper health checks | ALB/NLB |
Scaling Anti-Patterns (Exam Traps)
- Scaling on memory: CloudWatch does NOT collect memory metrics by default. Must install CloudWatch Agent first. Questions may trick you into choosing memory-based scaling without mentioning the agent.
- Scaling too aggressively: Without cooldown periods, ASG can oscillate (scale out → scale in → scale out). Target tracking handles this automatically.
- Single AZ scaling: ASG should span 2-3 AZs. Single AZ = single point of failure even with scaling.
- Ignoring warm-up time: New instances need time to be healthy. ALB health checks must account for application startup time.
Exam Tips
| Exam | Key Points |
|---|---|
| SAP-C02 | “Simplest scaling policy” → Target Tracking. “Recurring daily pattern, pre-scale” → Predictive Scaling. “Scale workers based on queue depth” → SQS backlog per instance. “Reduce cold start” → Provisioned Concurrency (Lambda) or Warm Pools (EC2). “Memory-based scaling” → needs CloudWatch Agent first. “Instance takes 5 min to boot” → Warm Pools or increase health check grace period. “Scale to zero” → Fargate/Lambda (EC2 ASG min=0 with Warm Pool). |
AWS Certification Exam Practice Questions
Question 1:
A web application experiences predictable traffic spikes every weekday at 9 AM and 5 PM. Currently, the ASG with target tracking reacts to the spike, but for 3-4 minutes users experience slow responses while new instances warm up. How can the company eliminate this warm-up delay?
- Reduce the target tracking threshold from 50% to 30% CPU
- Add Predictive Scaling policy — ML learns the daily pattern and pre-scales before the spike arrives
- Increase the ASG maximum capacity permanently
- Switch from target tracking to step scaling with aggressive thresholds
Show Answer
Answer: B — Predictive Scaling uses ML to analyze historical patterns (daily, weekly cycles) and proactively scales capacity BEFORE the predicted spike. Instances are ready when traffic arrives — no warm-up delay. Lowering target (A) wastes money during off-peak. Higher max (C) doesn’t help timing. Step scaling (D) still reacts after traffic arrives. You can use Predictive + Target Tracking together (predictive for pattern, target tracking for unexpected spikes).
Question 2:
An application processes messages from an SQS queue using an ASG of EC2 workers. Each message takes 30 seconds to process. The company wants the ASG to scale based on the backlog — keeping processing time under 5 minutes per message. Which scaling metric achieves this?
- Target tracking on CPUUtilization at 70%
- Target tracking on custom metric: ApproximateNumberOfMessages / RunningInstances (backlog per instance), target = 10 messages per instance
- Step scaling on ApproximateNumberOfMessages > 100
- Scheduled scaling based on known message arrival patterns
Show Answer
Answer: B — Backlog per instance is the recommended SQS scaling metric. If each message takes 30s and target latency is 5 min (300s), each instance can process 10 messages within target time (300/30=10). Set target=10 messages per instance. As backlog grows beyond 10 per instance, ASG adds workers. CPU (A) doesn’t reflect queue depth. Raw queue length (C) doesn’t account for instance count. This is the AWS-recommended approach in the Auto Scaling docs.
Question 3:
A Lambda function connected to API Gateway experiences cold starts of 3-5 seconds during the first request after idle periods. Business requires consistent sub-second response times for all requests. Which solution eliminates cold starts?
- Increase Lambda memory allocation to speed up initialization
- Configure Provisioned Concurrency for the function to keep execution environments warm
- Use a CloudWatch Events rule to ping the function every 5 minutes
- Move to Fargate to eliminate cold starts entirely
Show Answer
Answer: B — Provisioned Concurrency keeps a specified number of execution environments initialized and ready to respond instantly. No cold start — function starts executing immediately. More memory (A) speeds up cold start but doesn’t eliminate it. Pinging (C) is a hack that doesn’t scale (only keeps 1 instance warm) and still has cold starts under load. Provisioned Concurrency is the official solution and works with Auto Scaling to adjust concurrency based on usage schedules.
Question 4:
A company’s ASG uses EC2 instances that take 7 minutes to fully initialize (download configs, warm caches). During scale-out events, the ALB marks new instances as unhealthy and terminates them before they finish starting. How should this be fixed?
- Remove health checks from the ALB
- Increase the ASG health check grace period to 420 seconds (7 minutes) and configure Warm Pools with pre-initialized instances
- Change to simple scaling with a 10-minute cooldown
- Use a smaller AMI that boots faster
Show Answer
Answer: B — Health check grace period tells ASG to ignore health check failures during startup (default 300s). Set it to exceed your initialization time (420s > 7 min). Warm Pools keep instances pre-initialized (already booted, configs downloaded) — when ASG scales out, instances from warm pool are ready in seconds, not 7 minutes. Removing health checks (A) means unhealthy instances stay in service. Smaller AMI (D) may not be feasible.
Question 5:
A company wants to scale their EC2 fleet based on memory utilization, maintaining 60% average across the group. When they configure target tracking with MemoryUtilization, it fails because the metric doesn’t exist. What is the issue and fix?
- MemoryUtilization requires Enhanced Monitoring to be enabled on EC2
- Install the CloudWatch Agent on all instances to publish custom MemoryUtilization metric, then create target tracking policy on that custom metric
- Memory metrics are only available on Nitro instances
- Use CPUUtilization instead — it correlates with memory usage
Show Answer
Answer: B — CloudWatch does NOT collect memory metrics from EC2 by default (only CPU, network, disk I/O). You must install the CloudWatch Agent, configure it to publish memory metrics, then use that custom metric in your scaling policy. Enhanced Monitoring (A) is for RDS, not EC2. CPU (D) doesn’t correlate with memory for memory-bound workloads. This is a classic exam trap — many candidates assume memory metrics exist natively.
Related Posts
- Three-Tier Web & Caching Architecture
- Cost Optimization Architecture
- Serverless API Architecture
- Container Platform Architecture
References
- Target Tracking Scaling Policies — AWS Docs
- Predictive Scaling — AWS Docs
- ECS Auto Scaling with Custom Metrics — AWS Blog
- Warm Pools — AWS Docs
Frequently Asked Questions
Target Tracking vs Step Scaling — which should I use?
Target Tracking for most workloads — it’s simpler (set a target, ASG does the rest) and handles both scale-out and scale-in automatically. Step Scaling when you need different responses at different alarm levels (e.g., add 1 instance at 60% CPU but add 5 instances at 90% CPU). You can combine both: target tracking for normal patterns plus a step policy for extreme spikes.
What is Predictive Scaling?
Predictive Scaling uses ML to analyze 14 days of historical metrics, identify recurring patterns (daily peaks, weekly cycles), and proactively adjust capacity BEFORE demand arrives. It creates a forecast and schedules scaling actions ahead of time. Best paired with target tracking — predictive handles the pattern, target tracking handles unexpected spikes. Zero cost beyond the instances launched.
How do Warm Pools reduce scaling time?
Without Warm Pools, scale-out launches a new instance from AMI (boot OS, download configs, register with ELB — potentially 5-10 minutes). With Warm Pools, instances are pre-initialized (already booted and configured) in a “stopped” state. Scale-out simply starts a stopped instance (seconds) and registers with the target group. You pay only for EBS storage while stopped, not compute.