【发布时间】:2026-01-16 01:15:01
【问题描述】:
我正在尝试设置一个基于平均组 CPU 负载自动扩展的 AWS Auto Scaling 组 (ASG)。
我有一个扩展策略,一旦平均 CPU 使用率高于 70%,就应该将组扩展 1 个实例。但是,当触发警报时,ASG 会同时启动多个实例,这是不应该的。
CloudFormation 配置相关位:
ECSScaleUpPolicy:
Type: AWS::AutoScaling::ScalingPolicy
Properties:
AdjustmentType: "ChangeInCapacity"
AutoScalingGroupName: !Ref ECSAutoScalingGroup
PolicyType: "StepScaling"
MetricAggregationType: "Average"
EstimatedInstanceWarmup: 600
StepAdjustments:
-
MetricIntervalLowerBound: "0"
ScalingAdjustment: "1"
ECSScaleUpAlarm:
Type: "AWS::CloudWatch::Alarm"
Properties:
AlarmDescription: "CPU more than 70% during the last minute."
AlarmName: "ECSScaleUpAlarm"
AlarmActions:
-
!Ref ECSScaleUpPolicy
Dimensions:
-
Name: "ClusterName"
Value: !Ref ECSCluster
MetricName: "CPUReservation"
Namespace: "AWS/ECS"
ComparisonOperator: "GreaterThanOrEqualToThreshold"
Statistic: "Average"
Threshold: 70
Period: 60
EvaluationPeriods: 1
TreatMissingData: "notBreaching"
如您所见,缩放调整仅为 1,并且实例预热时间很长,在启动第二个实例之前应该等待更多时间:(
【问题讨论】:
标签: amazon-web-services amazon-cloudformation autoscaling