AWS fargate 中 Auto-Scaling 策略的区别

Difference between Auto-Scaling Policies in AWS fargate

我开始探索 Amazon Web Service 中的 fargate,它按预期工作。
现在,当我尝试应用不同的自动缩放策略时,我无法区分 Step-Scaling目标跟踪政策

我了解步进缩放策略是:

我们指定了多个阈值以及不同的响应。

阈值 A - 当 CPU 利用率介于 40% 和 50% 之间时添加 1 个实例

阈值 B - 当 CPU 利用率介于 50% 和 70% 之间时添加 2 个实例

阈值 C - 当 CPU 利用率介于 70% 和 90% 之间时添加 3 个实例

等等等等

(即)有多个阈值

1) 但是我不明白目标跟踪策略是如何工作的?
2) 不确定步长缩放和目标跟踪策略之间的区别

谢谢,
哈利

AWS Fargate 中自动扩展策略之间的差异(步进扩展与目标跟踪)

步进缩放

步进扩展策略根据您指定的一组扩展调整(称为步进调整)增加或减少当前容量。使用步进缩放,您可以控制缩放调整

看这里: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-autoscaling-stepscaling.html

目标追踪

使用目标跟踪扩展策略,Amazon ECS 创建和管理 触发扩展策略的 CloudWatch 警报,并计算 扩展调整基于CloudWatch 指标和您指定的目标值。借助目标跟踪,AWS 根据您的目标自动控制缩放调整

With target tracking scaling policies, you select a CloudWatch metric and set a target value. Amazon ECS creates and manages the CloudWatch alarms that trigger the scaling policy and calculates the scaling adjustment based on the metric and the target value. The scaling policy adds or removes service tasks as required to keep the metric at, or close to, the specified target value.

https://docs.aws.amazon.com/AmazonECS/latest/userguide/service-autoscaling-targettracking.html

例如,如果您将平均 CPU 利用率设置为 90%,Amazon ECS 将调整任务数(开始或停止任务)以保持此目标。

注意:为了未来读者的利益,为了更有效地针对主题行中的问题(而不是迎合提问者的具体问题),此答案已经过修改。

我会尽量回答你的问题。

  1. But I couldn't understand how the target tracking policy works?

嗯,AWS 会根据您指定的目标为您创建 Cloudwatch 警报。它监视警报,并在发生任何警报违规时尝试通过缩小或缩小使指标保持在目标值附近。此外,由于负载模式的变化,目标跟踪扩展策略也会根据指标的变化进行调整。

  1. Not sure about the difference between Step scaling and Target Tracking policy

如果我确定我的扩展指标 increases/decreases 与自动扩展组中的实例数量成比例,我会选择目标跟踪策略。另一方面,如果我想要更细粒度地控制缩放或缩小,我会进行逐步缩放,例如我在负载均衡器后面有一个实时 websocket 应用程序(使用最少的连接算法)和平均 CPU 利用率突然开始超过 80,我可能会添加 3-4 个实例,以便所有新连接都路由到我的新实例,让其他实例喘口气。

So if I understand correctly, in step scaling we need to specify the alarm range as I mentioned in the question but in target tracking, we need to specify one target value like 90 percent which indicates that it if the instances has 90 percent of CPU then it spans another one?

是的,没错。 AWS ECS 负责生成另一个 task/instance,以便它可以检查指标。

It makes sure it maintains the 90 percent max CPU in all the instances Say if my target value is 90 percent?

不,它不能确保如果您的目标值为 90%,则所有实例都将低于 90%CPU。目标值通常是缩放组中所有实例的平均指标。您可以定义自己的指标,但应与目标跟踪策略兼容。您可以在此处找到更多相关信息 (https://docs.aws.amazon.com/autoscaling/ec2/userguide/as-scaling-target-tracking.html)。