Auto Scaling Group
AWS Auto Scaling Groups (ASG) 筆記。
Scalability & High Availability
Scalability
Scalability 指應用程式/系統可以透過調整來處理更大的負載。分為兩種:
- Vertical Scalability: 增加實例大小(如 t2.micro → t2.large)
- Horizontal Scalability (Elasticity): 增加實例數量
High Availability
- 通常與 Horizontal Scaling 搭配
- 在至少 2 個 AZ 中運行應用程式
- 目標是在資料中心故障時能夠存活
Summary
| 類型 | 說明 |
|---|---|
| Vertical Scaling | 增加實例大小 (Scale up/down) |
| Horizontal Scaling | 增加實例數量 (Scale out/in) - ASG, Load Balancer |
| High Availability | 跨多個 AZ 運行實例 - ASG Multi-AZ |
Scalability vs Elasticity vs Agility
| 概念 | 說明 |
|---|---|
| Scalability | 透過增強硬體 (scale up) 或增加節點 (scale out) 來容納更大負載 |
| Elasticity | 系統可擴展後,自動擴展功能讓系統根據負載自動調整。Cloud-friendly: pay-per-use |
| Agility | 新 IT 資源只需點擊即可獲得,將資源可用時間從數週縮短到數分鐘 |
Auto Scaling Group
旨在自動啟動或終止 Amazon EC2 執行個體,以確保擁有足夠的執行個體數量來處理應用程式負載。
Goals
- Scale out (add EC2 instances) to match increased load
- Scale in (remove EC2 instances) to match decreased load
- Ensure minimum and maximum number of machines running
- Automatically register new instances to a load balancer
- Replace unhealthy instances
- Cost Savings: Only run at optimal capacity

With ELB

Scaling Strategies
Manual Scaling
手動調整 ASG 大小。
Dynamic Scaling
Simple / Step Scaling
- When CloudWatch alarm triggered (e.g. CPU > 70%) → add 2 units
- When CloudWatch alarm triggered (e.g. CPU < 30%) → remove 1 unit
Target Tracking Scaling
- Want the average ASG CPU to stay at around 40%
Scheduled Scaling
- Anticipate scaling based on known usage patterns
- e.g. increase min capacity to 10 at 5 PM on Fridays
Predictive Scaling
根據歷史數據預測負載,提前自動調整容量。
