为啥 AWS Auto Scaling 在扩展期间会启动多个实例?
Posted
技术标签:
【中文标题】为啥 AWS Auto Scaling 在扩展期间会启动多个实例?【英文标题】:Why does AWS Auto Scaling launch multiple instances during scaling?为什么 AWS Auto Scaling 在扩展期间会启动多个实例? 【发布时间】:2019-01-06 13:25:19 【问题描述】:我正在尝试设置一个基于平均组 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,并且实例预热时间很长,在启动第二个实例之前应该等待更多时间:(
【问题讨论】:
【参考方案1】:根据documentation 策略类型Step scaling
导致组容量根据警报违规的大小增加或减少。您需要将其更改为Simple scaling
,以便可以根据单个调整设置容量。
【讨论】:
好像不是这样:Simple scaling: execute policy when: ECSScaleUpAlarm breaches the alarm threshold: CPUReservation >= 70 for 3 consecutive periods of 60 seconds for the metric dimensions. Take the action: Add 1 instances And then wait: 200 seconds before allowing another scaling activity
然而,立即启动了 2 个实例。以上是关于为啥 AWS Auto Scaling 在扩展期间会启动多个实例?的主要内容,如果未能解决你的问题,请参考以下文章
在 AWS 中缩减 Auto Scaling 组会导致永久警报