Amazon ECS 中的最小健康百分比和最大百分比是多少

What is the minimum healthy percent and maximum percent in Amazon ECS

我已经有了 Docker 和 EC2 的经验。但我是 ECS 的新手。谁能帮我理解这两个参数的实际作用,它们的区别和用法。

Official Docs 说:

The minimum healthy percent represents a lower limit on the number of your service's tasks that must remain in the RUNNING state during a deployment, as a percentage of the desired number of tasks (rounded up to the nearest integer). This parameter enables you to deploy without using additional cluster capacity. For example, if your service has a desired number of four tasks and a minimum healthy percent of 50%, the scheduler may stop two existing tasks to free up cluster capacity before starting two new tasks. Tasks for services that do not use a load balancer are considered healthy if they are in the RUNNING state; tasks for services that do use a load balancer are considered healthy if they are in the RUNNING state and the container instance it is hosted on is reported as healthy by the load balancer. The default value for minimum healthy percent is 50% in the console and 100% for the AWS CLI, the AWS SDKs, and the APIs.

The maximum percent parameter represents an upper limit on the number of your service's tasks that are allowed in the RUNNING or PENDING state during a deployment, as a percentage of the desired number of tasks (rounded down to the nearest integer). This parameter enables you to define the deployment batch size. For example, if your service has a desired number of four tasks and a maximum percent value of 200%, the scheduler may start four new tasks before stopping the four older tasks (provided that the cluster resources required to do this are available). The default value for maximum percent is 200%.

这两个参数我还是没搞清楚

  1. 对于最小健康百分比,如果我的服务有所需数量的 4 个任务并且最小健康百分比为 25%,那么调度程序 start/stop 将执行多少 existing/new 个任务?
  2. 对于最大百分比,如果我的服务有 4 个任务的所需数量和最大百分比值 50%,调度程序 start/stop 将执行多少 existing/new 个任务?
  3. 如果我的服务只有一个任务 运行,如何设置这些参数来停止现有任务和新任务 运行。
  1. 所需任务为 4,最低运行状况为 25%,然后在部署期间允许 ECS 在开始新任务之前停止除 1 以外的所有任务
  2. 最大值应为 100+,这样配置就没有意义了。但是,如果您有 4 个所需任务并且最大为 150%,则允许 ECS 在停止其他任务之前启动 2 个新任务。
    • 如果您想确保在重新部署期间不超过 1 个任务 运行ning,那么您需要将 desired 设置为 1,最小值设置为 0%,最大值设置为 100%。
    • 如果您想确保始终至少有 1 个任务 运行ning 您需要将 desired 设置为 1,最小为 100%,最大为 200%。

其他例子。如果您希望达到 4,则最低为 50%,最高为 150%。然后 ECS 可以决定它在部署期间将做什么。

  • 如果集群没有更多资源可以决定停止2个任务,在新版本中启动2个新任务,等待新任务健康。然后停止剩下的两个任务,开始两个新的任务。
  • 如果集群有更多资源,则 ECS 可以决定在停止现有任务之前启动两个新任务。

或者你可以这样看。在重新部署期间,ECS 需要 运行 在 MinimumPercent/100*desired 和 MaximumPercent/100*desired 任务之间。在这种情况下,在 2-6 个任务之间。