MODULE 9 - Auto Scaling
Overview
This module delves into AWS Auto Scaling, the service that automatically adjusts the number of instances based on the load. You will learn how to configure effective scaling policies.
Learning Objectives
- Understand Auto Scaling Groups (ASG)
- Configure different scaling policies
- Choose the right metrics and thresholds
- Properly size an application
- Avoid common mistakes
Weekly Content
1. Auto Scaling Group (ASG)
┌─────────────────────────────────────────────────────────────┐
│ AUTO SCALING GROUP │
├─────────────────────────────────────────────────────────────┤
│ │
│ Basic parameters: │
│ • Minimum: 2 instances (always) │
│ • Desired: 2 instances (normal) │
│ • Maximum: 10 instances (peak) │
│ │
│ Normal load High load │
│ │
│ ┌───┐ ┌───┐ ┌───┐ ┌───┐ ┌───┐ ┌───┐ │
│ │ 1 │ │ 2 │ ────► │ 1 │ │ 2 │ │ 3 │ │ 4 │ │
│ └───┘ └───┘ └───┘ └───┘ └───┘ └───┘ │
│ Desired: 2 Desired: 4 │
│ │
│ Scale Out (add) │
│ ◄──────────────── │
│ Scale In (remove) │
│ │
└─────────────────────────────────────────────────────────────┘
2. Scaling Policies
| Type | Description | Use Case |
|---|---|---|
| Target Tracking | Maintains a target metric | CPU at 70%, simplest |
| Step Scaling | Step actions | Gradual response |
| Simple Scaling | One action at a time | Basic cases |
| Scheduled | Scheduled times | Predictable patterns |
| Predictive | Predictive ML | Predictable loads |
3. Target Tracking (Recommended)
┌─────────────────────────────────────────────────────────────┐
│ TARGET TRACKING │
├─────────────────────────────────────────────────────────────┤
│ │
│ "Keep average CPU at 70%" │
│ │
│ CPU% │
│ 100│ │
│ │ ┌────┐ │
│ 90│ │ │ Scale Out │
│ │ │ ▼ │
│ 70│──────┴────────────────── Target: 70% │
│ │ ┌────┐ │
│ 50│ │ │ Scale In │
│ │ │ ▼ │
│ 30│ └───────────── │
│ └────────────────────────────► Time │
│ │
│ AWS automatically adjusts the number of instances │
│ to maintain the target. │
│ │
└─────────────────────────────────────────────────────────────┘
4. Common Metrics
| Metric | Typical Threshold | Notes |
|---|---|---|
| CPUUtilization | 70% | Most used |
| RequestCountPerTarget | Variable | For ALB |
| MemoryUtilization | 80% | Requires CloudWatch agent |
| Custom | Variable | Application metrics |
5. Common Mistakes
❌ MISTAKES TO AVOID
1. Cooldown too short
→ Oscillations (repeated scale up/down)
→ Solution: Cooldown 300+ seconds
2. Thresholds too close
→ Immediate scale-in after scale-out
→ Solution: Min 20% gap between thresholds
3. Min = Max = Desired
→ No scaling at all!
→ Solution: Min < Desired < Max
4. No health check
→ Unhealthy instances kept
→ Solution: Configure ASG health checks
5. Instance too slow to start
→ Lost requests during scale-out
→ Solution: Optimized AMI, warmup period
Exercise: ASG Configuration
Scenario
E-commerce application with:
- Normal traffic: 100 req/s
- Sales peak: 1000 req/s
- t3.medium instance handles 200 req/s
Questions
- How many minimum instances?
- How many maximum instances?
- What scaling policy?
- What thresholds do you configure?
Deliverable
Scaling Analysis:
- Proposed ASG configuration
- Justification of thresholds
- Load increase simulation
- Cost calculation
Navigation
- Auto Scaling Concepts
- Scaling Policies
- Validation Quiz - 30 questions to validate your knowledge
- Lab: Auto Scaling
Next week: MODULE 10 - DNS and Route 53