为什么AWS Auto Scaling在扩展期间会启动多个实例?

时间:2018-07-30 10:02:22

标签: amazon-web-services amazon-cloudformation autoscaling

我正在尝试建立一个AWS Auto Scaling组(ASG),该组将根据组的平均CPU负载自动进行扩展。

我有一个扩展策略,该策略应该在平均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 个答案:

答案 0 :(得分:3)

根据Step scaling的{​​{3}}策略类型,组容量根据警报突破的大小而增加或减少。您需要将其更改为Simple scaling,以便可以基于单个调整来设置容量。