
Scaling Policy는 ASG의 인스턴스 수를 “언제, 얼마나” 바꿀지 결정하는 규칙. 실무 기본은 Target Tracking이고, 보조로 Step/Simple, Scheduled, Predictive를 상황에 맞게 조합.
| 유형 | 추천도 | 개념 | 언제 쓰나 |
|---|---|---|---|
| Target Tracking | ⭐️⭐️⭐️⭐️⭐️ (권장) | “지표를 목표값으로 자동 추종” | 대부분의 웹/API, 안정적인 자동화 |
| Step Scaling | ⭐️⭐️⭐️⭐️ | 임계 초과 정도에 따른 단계적 증감 | 스파이크 대응(급격한 증설) |
| Simple Scaling | ⭐️⭐️ | 임계 초과시 고정 증감 + Cooldown | 레거시, 가급적 Step/Target로 대체 |
| Scheduled Scaling | ⭐️⭐️⭐️ | 시간표 기반 증감 | 업무시간/이벤트 예약 증설 |
| Predictive Scaling | ⭐️⭐️⭐️ | 패턴 예측 기반 선제 스케일 | 일/주기 패턴 뚜렷한 서비스 |
원리: 목표값(TargetValue)을 유지하도록 자동 증감
ASGAverageCPUUtilization = 50%ALB RequestCountPerTarget = 100 (타깃 1대당 초당 요청 수)장점: 알람/경계치 설계 불필요, 자동으로 상·하한을 추적
Warmup: InstanceWarmup(또는 ASG DefaultInstanceWarmup)을 꼭 설정(예: 120s~300s)
Scale-in 보호: 배포/캐시 워밍 등 상황에서 DisableScaleIn=true 로 축소를 잠시 막을 수 있음
Predefined Metric (대표)
ASGAverageCPUUtilizationALBRequestCountPerTarget (필요: TargetGroup/LoadBalancer 지정)Customized Metric
ApproximateNumberOfMessagesVisible / InServiceInstancesCLI 예시
aws autoscaling put-scaling-policy \
--auto-scaling-group-name asg-web \
--policy-name tt-cpu50 \
--policy-type TargetTrackingScaling \
--target-tracking-configuration '{
"PredefinedMetricSpecification":{"PredefinedMetricType":"ASGAverageCPUUtilization"},
"TargetValue":50.0,
"DisableScaleIn":false
}'
원리: 임계를 얼마나 넘었는지에 따라 증감 폭을 다르게
구성 요소
ChangeInCapacity / PercentChangeInCapacity / ExactCapacityCooldown: 정책/그룹의 쿨다운을 활용해 플래핑 방지
팁: 상방(Scale-out)만 Step으로 크게, 하방(Scale-in)은 Target Tracking으로 완만히 조합 가능
CLI 예시 (요약)
# 1) 알람(예: CPU >= 70% 2분 지속)
aws cloudwatch put-metric-alarm \
--alarm-name cpu-high \
--metric-name CPUUtilization --namespace AWS/EC2 \
--statistic Average --period 60 --evaluation-periods 2 \
--threshold 70 --comparison-operator GreaterThanOrEqualToThreshold \
--dimensions Name=AutoScalingGroupName,Value=asg-web \
--alarm-actions arn:aws:autoscaling:...:scalingPolicy:policyID:autoScalingGroupName/asg-web:policyName/step-out \
--treat-missing-data notBreaching
# 2) 단계별 증설 정책
aws autoscaling put-scaling-policy \
--auto-scaling-group-name asg-web \
--policy-name step-out \
--policy-type StepScaling \
--adjustment-type PercentChangeInCapacity \
--step-adjustments '[
{"MetricIntervalLowerBound": 0, "MetricIntervalUpperBound": 10, "ScalingAdjustment": 20},
{"MetricIntervalLowerBound": 10, "MetricIntervalUpperBound": 30, "ScalingAdjustment": 40},
{"MetricIntervalLowerBound": 30, "ScalingAdjustment": 60}
]' \
--estimated-instance-warmup 120
CLI 예시
aws autoscaling put-scheduled-update-group-action \
--auto-scaling-group-name asg-web \
--scheduled-action-name scale-office-hours \
--recurrence "0 0 0 ? * MON-FRI *" \
--desired-capacity 20
PredictiveScaling 정책 + Load Metric(예: ALBRequestCountPerTarget) 지정ForecastOnly(예측만) / ForecastAndScale(예측+선제 증설)CLI 예시(요약)
aws autoscaling put-scaling-policy \
--auto-scaling-group-name asg-web \
--policy-name predictive-req \
--policy-type PredictiveScaling \
--predictive-scaling-configuration '{
"MetricSpecifications":[
{"TargetValue":100.0,
"PredefinedMetricPairSpecification":{
"PredefinedMetricType":"ALBRequestCount",
"ResourceLabel":"app/my-alb/1234567890abcdef/targetgroup/tg-web/abcdef1234567890"
}
}
],
"Mode":"ForecastAndScale",
"SchedulingBufferTime":300
}'
실제 파라미터 이름/구성은 콘솔 가이드를 함께 확인해 세팅하세요. (리소스 라벨 형식 엄격)
Instance Warmup: 새 인스턴스가 정상 처리가 가능해질 때까지 지표 반영 제외
InstanceWarmup(정책별) 또는 ASG DefaultInstanceWarmupEstimatedInstanceWarmup 또는 그룹 DefaultCooldownDisableScaleIn: 특정 정책에서 축소 금지
Scale-In Protection: 인스턴스 단위로 축소 보호
Lifecycle Hooks: Launch/Terminate 시 초기화/드레인 스크립트 실행
ALBRequestCountPerTarget + Target TrackingASGAverageCPUUtilizationResources:
CpuTargetTracking:
Type: AWS::AutoScaling::ScalingPolicy
Properties:
AutoScalingGroupName: !Ref Asg
PolicyType: TargetTrackingScaling
TargetTrackingConfiguration:
PredefinedMetricSpecification:
PredefinedMetricType: ASGAverageCPUUtilization
TargetValue: 50
DisableScaleIn: false
StepOut:
Type: AWS::AutoScaling::ScalingPolicy
Properties:
AutoScalingGroupName: !Ref Asg
PolicyType: StepScaling
AdjustmentType: PercentChangeInCapacity
EstimatedInstanceWarmup: 120
StepAdjustments:
- MetricIntervalLowerBound: 0
MetricIntervalUpperBound: 10
ScalingAdjustment: 20
- MetricIntervalLowerBound: 10
ScalingAdjustment: 40