ECS缩小未能降低所需数量

时间:2018-06-06 01:03:48

标签: amazon-web-services scaling terraform amazon-ecs

我们的ECS的缩放非常简单。如果触发向外扩展警报,则向上扩展服务器:容器1:1。如果触发报警中的刻度,则执行相反的操作。扩展工作,但按比例缩小有一些奇怪的行为。

当缩小比例时,EC2实例消失并带有一个容器。但是,应该在ECS服务上将期望计数降低1的相同警报不会。这是用于处理所需计数的政策的按比例缩小的terraform代码:

resource "aws_appautoscaling_policy" "service_scaling_down" {
  name = "ecs-service-scaling-down"
  resource_id = "service/${aws_ecs_cluster.main.name}/${aws_ecs_service.pdfd-service.name}"
  scalable_dimension = "ecs:service:DesiredCount"
  service_namespace = "ecs"

  step_scaling_policy_configuration {
    adjustment_type = "ChangeInCapacity"
    cooldown = 60
    metric_aggregation_type = "Minimum"

    step_adjustment {
      scaling_adjustment = -1
      metric_interval_upper_bound = 0 
    }
  }

  depends_on = [
    "aws_appautoscaling_target.ecs_service_target"
  ]
}

和缩小警报本身..

resource "aws_cloudwatch_metric_alarm" "alrm-scale-down-queue" {
  alarm_name                = "ecs-queue-scale-down-alarm"
  comparison_operator       = "LessThanThreshold"
  evaluation_periods        = "1"
  metric_name               = "InstanceScaleCount"
  namespace                 = "ecs-pdfd" 
  period                    = "60"
  statistic                 = "Minimum"
  threshold                 = "0.1"  
  alarm_description         = "ECS queue time monitor, scale down"
  insufficient_data_actions = []

  alarm_actions = [
    "${aws_autoscaling_policy.instance_scale_down.arn}",
    "${aws_appautoscaling_policy.service_scaling_down.arn}"
  ]
}

实例缩小策略似乎在此警报中正常工作。但不是服务扩展。什么可能导致规模下降不能正确改变所需的数量?

0 个答案:

没有答案