Resilient Cloud Solutions · Topic 3 of 5
Scalability and Decoupling
Scale compute and data tiers with Auto Scaling policies, lifecycle hooks, warm pools, queues, caching and serverless scaling to meet changing demand.
- 5 min
- Target tracking is the simplest and usually correct policy.
- Scheduled scaling suits known peaks; predictive scaling suits repeating patterns.
- Scale queue consumers on backlog per instance.
What it is
A scalable system adds or removes capacity as demand changes, without a person intervening and without redesign. Scaling out (more instances) is preferred to scaling up (bigger instances), because it also adds redundancy.
Scaling works best when tiers are decoupled. A queue or event stream between producer and consumer lets each side scale at its own pace and absorbs bursts.
How it works
EC2 Auto Scaling policies
An Auto Scaling group (ASG) has a minimum, desired and maximum size, a launch template and scaling policies.
| Policy | Behavior | Choose when |
|---|---|---|
| Target tracking | Keeps a metric near a target, like average CPU at 50 percent | The default choice, simplest |
| Step scaling | Adds or removes different amounts by alarm size | Large variations need proportional responses |
| Simple scaling | One adjustment, then a cooldown | Legacy, rarely best |
| Scheduled | Changes capacity at set times | Known events such as a daily peak |
| Predictive | Forecasts load from history and scales ahead | Regular cyclical traffic |
Common target tracking metrics are average CPU utilization and ALBRequestCountPerTarget. For queue consumers, scale on a custom metric such as the backlog per instance (queue length divided by the number of instances), not on CPU alone.
The warm up setting tells the group how long a new instance takes before its metrics count. A cooldown prevents the group from adding or removing instances again too soon.
Making scale out faster
- Pre baked AMIs reduce boot time compared with installing software at launch.
- Warm pools keep pre initialized instances stopped or running ready to join, which shortens scale out.
- Lifecycle hooks pause an instance in
Pending:WaitorTerminating:Waitso you can run custom actions, such as registering with a service or draining logs, and then continue.
aws autoscaling complete-lifecycle-action --lifecycle-hook-name drain-hook \
--auto-scaling-group-name web-asg --lifecycle-action-result CONTINUE \
--instance-id i-0123456789abcdef0
If the hook times out, the default result applies, which is configurable as continue or abandon.
Mixed fleets and cost
A mixed instances policy combines On Demand instances with Spot Instances across several instance types, which lowers cost. Diversify types and AZs so a Spot interruption in one pool does not stall the group.
Containers and serverless
| Service | Scaling mechanism |
|---|---|
| ECS service | Application Auto Scaling with target tracking on CPU, memory or request count; capacity providers add instances or Fargate capacity |
| EKS | Kubernetes autoscalers on pods and nodes |
| Lambda | Scales out by running more function instances; reserved concurrency caps it, provisioned concurrency keeps instances warm |
| API Gateway | Throttling limits protect the backend; caching reduces load |
Scaling data and reads
Databases scale differently from stateless compute.
- RDS: scale up the instance size, add read replicas, and add a cache.
- Aurora: add readers (Aurora Auto Scaling can add and remove them by metric) or use Serverless v2 for capacity that follows load.
- DynamoDB: on demand capacity mode scales with no planning, while provisioned mode uses Application Auto Scaling for the read and write capacity units. DynamoDB Accelerator (DAX) adds an in memory cache for reads.
- ElastiCache: an in memory cache in front of the database cuts repeated reads.
- Amazon CloudFront: serves cached content from edge locations and takes load off the origin.
Decoupling tools
| Service | Use |
|---|---|
| Amazon SQS | Queue, many consumers, buffers bursts; use a dead letter queue for failed messages |
| Amazon SNS | Fan out one message to many subscribers |
| Amazon Kinesis Data Streams | Ordered, replayable stream, scaled by shards |
| Amazon EventBridge | Route events by rules between services |
With SQS, a consumer fleet scales on the backlog, and the queue absorbs a spike so nothing is lost while capacity catches up.
Instance refresh
Instance refresh replaces instances in an ASG gradually after a launch template change, with a minimum healthy percentage, which is a scaling group level rolling deployment.
What to remember for the exam
- Target tracking is the simplest and usually correct policy.
- Scheduled scaling suits known peaks; predictive scaling suits repeating patterns.
- Scale queue consumers on backlog per instance.
- Warm pools and pre baked AMIs shorten scale out time.
- Lifecycle hooks pause instances for custom work and have a timeout.
- Mixed instances policies use Spot plus On Demand to save cost.
- Lambda reserved concurrency caps a function; provisioned concurrency avoids cold starts.
- DynamoDB on demand removes capacity planning; DAX caches reads.
- A queue between tiers absorbs bursts and lets each tier scale separately.
If the problem is slow instance start during a spike, pick warm pools or a pre baked AMI before changing the scaling metric.
Common mistakes
Scaling a queue worker on CPU. CPU may stay low while the queue grows, so the backlog metric is a better signal.
Skipping the warm up time. New instances report low metrics and trigger extra scale out.
Relying on one instance type with Spot. One capacity shortage stops the group.
Using bigger instances only. Scaling up has a ceiling and keeps a single point of failure.
Lambda scaling can overwhelm a downstream database with too many connections, so use reserved concurrency or RDS Proxy.
Check yourself
Which metric scales a fleet of queue workers best?
Backlog per instance, meaning queue length divided by the number of running workers.
What does a warm pool do?
It keeps pre initialized instances ready, so scale out completes faster.
How do you stop Lambda from overloading a database?
Set reserved concurrency on the function and consider RDS Proxy for connection pooling.
Topic 3 of 5 in Resilient Cloud Solutions
Test yourself on Resilient Cloud Solutions
The full AWS DOP-C02 question bank has 844 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by AWS. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.