简体   繁体   English

部署期间,所需任务计入ECS服务

[英]Desired tasks count in ECS service during deployment

Let's say, I have a ECS service running. 假设我正在运行ECS服务。 It is configured to run at minimum 2 tasks, desired count is 2 and maximum tasks count is 10. Minimum healthy percent is set at 100, max percent set to 150. 它被配置为至少运行2个任务,期望的计数为2,最大任务计数为10。最小健康百分比设置为100,最大百分比设置为150。

The ECS service is managed using CloudFormation template. 使用CloudFormation模板管理ECS服务。

If I update my ECS service CloudFormation template by changing the docker image tag I want to use and apply those changes to the stack - a new deployment is started. 如果我通过更改要使用的docker image标签来更新我的ECS服务CloudFormation模板并将这些更改应用到堆栈,则将开始新的部署。

Assume, that before the deployment, the application was under a high load and tasks count was increased to the maximum of 10 running tasks by auto-scaling. 假设在部署之前,该应用程序处于高负载下,并且通过自动缩放将任务数增加到最多10个正在运行的任务。

What I expect from the ECS service deployment in such conditions is the following: 在这种情况下,我对ECS服务部署的期望如下:

  1. 10 old tasks are running. 10个旧任务正在运行。
  2. 5 new tasks are spawned. 产生了5个新任务。
  3. 5 old tasks are set to draining state. 将5个旧任务设置为耗尽状态。
  4. 5 old tasks are stopped. 5个旧任务已停止。
  5. 5 new tasks are spawned. 产生了5个新任务。
  6. Remaining 5 old tasks are set to draining state. 剩余的5个旧任务被设置为耗尽状态。
  7. 5 old tasks stopped. 5个旧任务停止了。

What I get is: 我得到的是:

  1. 8 old tasks are set to draining state. 将8个旧任务设置为耗尽状态。
  2. Desired count of new deployment set to 10 by auto-scaling. 通过自动扩展将新部署的所需计数设置为10。
  3. 5 new tasks are spawned. 产生了5个新任务。
  4. 8 old tasks are stopped. 停止了8个旧任务。
  5. 5 new tasks are spawned. 产生了5个新任务。
  6. 2 old tasks set to draining state. 2个旧任务设置为耗尽状态。
  7. 2 old tasks stopped. 2个旧任务停止了。

The issue is, that ECS does not take into the account the number of old tasks running before the deployment. 问题是,ECS并未考虑部署之前正在运行的旧任务的数量。 It tries to deploy with the desired count of 2, which is set originally in the CloudFormation template. 它尝试以期望的数量2进行部署,该数量最初在CloudFormation模板中设置。 This leads to unexpected termination of 8 tasks before the auto-scaling kicks in. 这会导致自动缩放开始前意外终止8个任务。

Is there a way to achieve something like the "expected" scenario during the new version deployment if the service is updated over CloudFormation? 如果通过CloudFormation更新服务,是否有办法在新版本部署期间实现“预期”方案? I know, I could manually change the desired count in the template before the deployment to the number of tasks, that is currently running. 我知道,我可以在部署前手动将模板中所需的计数更改为当前正在运行的任务数。 Maybe there is a better way? 也许有更好的方法?

If your desired count is 10 at a particular moment and you set minimum health percentage = 150 and the maximum percentage is 200. Then It will spawn 5 more task and initiate the draining of 5 old tasks. 如果您希望在特定时刻的计数是10,并且您将最小健康百分比设置为150,最大百分比设置为200,那么它将产生5个以上的任务并启动5个旧任务的消耗。

Also, you don't have to change the desired count and take care of the task which is in draining state. 另外,您不必更改所需的计数并处理处于耗尽状态的任务。 It will be drained once the connection will be closed. 连接一旦关闭,便会排干。

It appears, that it is possible to not provide the desired count . 似乎可能不提供所需的计数 Then, then the new deployment uses the old desired count. 然后,新部署将使用旧的所需计数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM