Auto Scaling and Elasticity: EC2, Caching, and Database Scaling
Elasticity is the ability of a workload to add capacity automatically when demand rises and shed it when demand falls, keeping performance steady without paying for idle resources. Task 2.1 of the SOA-C03 exam tests whether you can operate that machinery: EC2 Auto Scaling groups and their policy types, the metrics those policies track, warmup, cooldown and scale-in controls, scaling for ECS services and Lambda functions, the caching layers (CloudFront and ElastiCache) that absorb load before it reaches your compute, and the scaling controls built into RDS, Aurora and DynamoDB. The questions are operational, not architectural: a group that launches and terminates instances in a loop, an alarm in breach with nothing launching, a cache whose hit rate keeps falling, a read replica falling behind, a DynamoDB table throttling writes. This lesson works through the scaling mechanisms for the compute, cache and database tiers, compares the near-twin controls the exam likes to set against each other, and walks through the troubleshooting patterns its scenarios come from.
What you’ll learn
- Configure EC2 Auto Scaling groups with launch templates, min/max/desired capacity, health-check type and grace period
- Choose the right scaling policy (target tracking, step, simple, scheduled or predictive) and the right metric for it, including request count per target and SQS backlog per instance
- Explain how instance warmup, the default cooldown, scale-in protection, termination policies and lifecycle hooks interact
- Diagnose flapping, stuck-at-max capacity, launch failures and suspended processes in an Auto Scaling group
- Scale ECS services across both the task and the instance layer, and choose between Lambda reserved and provisioned concurrency
- Use CloudFront cache policies, Origin Shield and ElastiCache (Valkey, Redis OSS, Memcached, Serverless) to offload traffic, and read cache metrics such as Evictions and EngineCPUUtilization
- Scale RDS, Aurora and DynamoDB with instance class changes, storage autoscaling, read replicas, the right Aurora endpoint, capacity modes and DAX
The 11 parts · about 17 min of reading
- How an EC2 Auto Scaling group keeps capacity rightStart hereMin, max and desired capacity, versioned launch templates, mixed instances, ELB health checks and a grace period matching startup.2 min
- Scaling policy types comparedTarget tracking, step, simple, scheduled and predictive policies, and why a scheduled action should raise the minimum, not just desired.2 min
- Choosing the metric for target trackingTarget tracking needs a metric that falls as capacity grows: CPU, ALBRequestCountPerTarget, or SQS backlog per instance in messages.1 min
- Cooldowns, instance warmup, and lifecycle hooksThe default cooldown governs only simple scaling, instance warmup governs target tracking and step, and lifecycle hooks pause launches.1 min
- Controlling scale-inScale-in protection decides eligibility, the termination policy picks the instance, and a hook only delays it, with heartbeat limits.2 min
- Troubleshooting: flapping, stuck at max, and suspended processesFix flapping with target tracking and warmup, then diagnose an alarm with no launches: no headroom, failed launches or suspended processes.2 min
- Scaling beyond EC2ECS needs service scaling plus a managed-scaling capacity provider on EC2; Lambda is tuned with reserved and provisioned concurrency.1 min
- Caching for dynamic scalabilityCloudFront cache keys, origin request policies and Origin Shield cut origin load; ElastiCache engines differ in replication and failover.2 min
- ElastiCache topology, metrics, and scalingReplicas scale reads, shards scale writes and memory, and Evictions, Reclaimed and EngineCPUUtilization reveal what a cache needs.1 min
- Scaling RDS and AuroraResize RDS with a brief Multi-AZ failover, add replicas for reads, and reach auto-scaled Aurora Replicas through the reader endpoint.2 min
- Scaling DynamoDBOn-demand absorbs spikes while provisioned auto scaling suits steady load; throttling points to the mode, a hot key, or a need for DAX.1 min
Mind map
How the exam tests this
Task 2.1 questions hand you a demand pattern or a misbehaving fleet and ask for the best-fit control, often setting near-twins against each other: target tracking versus step versus predictive scaling, instance warmup versus the default cooldown, grace period versus target group threshold, scale-in protection versus a termination hook, AlarmNotification versus ScheduledActions, reserved versus provisioned concurrency. Expect arithmetic on target values (requests per target, backlog per instance) and metric reading: Evictions versus Reclaimed, EngineCPUUtilization versus CPUUtilization, ReplicaLag, throttle events. Database stems hinge on endpoints and modes: the reader endpoint for auto-scaled Aurora Replicas, a same-endpoint Multi-AZ resize versus a new-endpoint replica promotion, on-demand versus provisioned DynamoDB. Watch for answers that add availability (Multi-AZ, replicas) when the question asks for write capacity or memory, and read whether the goal is more capacity or more resilience before choosing.
Key takeaways
- "Keep a metric near a value" → target tracking, on a metric that falls as capacity is added: average CPU, ALBRequestCountPerTarget (not total RequestCount), or SQS backlog per instance.
- Backlog per instance target = acceptable wait ÷ processing time per message, a number of messages (120 s ÷ 4 s = 30).
- The default cooldown applies only to simple scaling; target tracking and step scaling use instance warmup, which keeps booting instances out of the aggregated metric.
- To pre-warm for a known peak, have the scheduled action raise min capacity (and lower it later); raising only desired is undone by target tracking.
- Predictive scaling needs recurring history; start in forecast only mode, and use a scheduling buffer for slow-booting instances.
- Scale-in protection keeps an instance from being selected; a termination hook only delays an instance already selected; OldestLaunchTemplate removes instances on an old template version first.
- Alarm in ALARM with no activities → check suspended processes (AlarmNotification); InsufficientInstanceCapacity → more Availability Zones and a mixed instances policy, not a quota increase.
- ECS on EC2 needs both service auto scaling (tasks) and an ASG capacity provider with managed scaling (instances); Lambda cold starts → provisioned concurrency, not reserved.
- CloudFront: keep the cache key to what changes the response; Origin Shield centralizes origin requests. ElastiCache: Evictions = memory pressure, Reclaimed = expired TTLs; replicas add reads, shards add writes and memory.
- Multi-AZ RDS resizes with a brief failover on the same endpoint; Aurora Replica auto scaling only helps clients on the reader endpoint; DynamoDB on-demand absorbs up to double the previous peak, and DAX adds microsecond reads without caching code.
Part 1: How an EC2 Auto Scaling group keeps capacity right
Min, max and desired capacity, versioned launch templates, mixed instances, ELB health checks and a grace period matching startup.
Frequently asked questions
What is the difference between target tracking and step scaling?
Target tracking holds a metric at a value you choose, such as average CPU at 50%, and AWS creates and manages the CloudWatch alarms and scales in both directions. Step scaling uses alarms you create plus step adjustments sized to how far the metric breached, and it can keep responding while a scaling activity is in progress. Use target tracking by default; use step scaling when you need different-sized responses at different severity levels.
Why does my Auto Scaling group keep launching and terminating instances repeatedly?
That is flapping. It usually comes from paired scale-out and scale-in policies with thresholds too close together, combined with booting instances dragging the average metric down so the scale-in policy fires. Fix it by replacing the pair with one target tracking policy, setting the group's default instance warmup to the time an instance takes to start serving, or widening the gap between the thresholds. Changing the default cooldown does not help, because it applies only to simple scaling policies.
What is the difference between scale-in protection and a termination lifecycle hook?
Scale-in protection removes an instance from selection when an Auto Scaling group scales in, so a busy instance is never chosen. A termination lifecycle hook acts after selection: it holds the chosen instance in Terminating:Wait for up to its heartbeat timeout (30 to 7,200 seconds, extendable with heartbeats to 48 hours or 100 times the timeout, whichever is smaller), and the instance still terminates afterwards. Use protection for long-running work and a hook for draining or cleanup.
Sign up free to mark lessons complete, bookmark topics and track your exam readiness.