ECS EC2 Scaling Policy for scaling in

Viewed 18

I'm learning about autoscaling for ECS with EC2.

I created a policy for scaling out.

  ASGScalingPolicyHigh: 
    Type: AWS::ApplicationAutoScaling::ScalingPolicy
    Properties:
      PolicyName: policy-high
      PolicyType: StepScaling
      ScalingTargetId:
        Ref: ServiceScalableTarget
      StepScalingPolicyConfiguration:
        AdjustmentType: ChangeInCapacity
        Cooldown: 600
        MetricAggregationType: Average
        StepAdjustments:
        - MetricIntervalLowerBound: 0
          MetricIntervalUpperBound: 15
          ScalingAdjustment: 1
        - MetricIntervalLowerBound: 15
          MetricIntervalUpperBound: 25
          ScalingAdjustment: 2
        - MetricIntervalLowerBound: 25
          ScalingAdjustment: 3

I also created the policy for scaling in

  ASGScalingPolicyDown: 
    Type: AWS::ApplicationAutoScaling::ScalingPolicy
    Properties:
      PolicyName: policy-down
      PolicyType: StepScaling
      ScalingTargetId:
        Ref: ServiceScalableTarget
      StepScalingPolicyConfiguration:
        AdjustmentType: ChangeInCapacity
        Cooldown: 600
        MetricAggregationType: Average
        StepAdjustments:
        - MetricIntervalLowerBound: -15
          MetricIntervalUpperBound: 0
          ScalingAdjustment: -1
        - MetricIntervalLowerBound: -25
          MetricIntervalUpperBound: -15
          ScalingAdjustment: -2
        - MetricIntervalUpperBound: -25
          ScalingAdjustment: -3

Every time the CPU usage goes up, I see the CW alarm for high usage in alarm state and the autoscaling starts adding tasks.

However, when the CPU usage goes down, the CW alarm for low usage gets in alarm state but the autoscaler doesn't start gradually removing tasks.

What am I doing wrong? Is the configuration of the StepAdjustments of the low policy right?

Thanks.

0 Answers
Related