简体   繁体   English

如何检测 ECS fargate 任务自动缩放事件,如 LifeCycleHook

[英]How to detect ECS fargate task autoscaling events like LifeCycleHook

I have ECS container running some tasks.我有 ECS 容器运行一些任务。 The server running inside the task may take 1~10 minutes to complete one request.任务内部运行的服务器可能需要 1~10 分钟才能完成一个请求。

I am using SQS for task queuing.我正在使用 SQS 进行任务排队。 When certain amount tasks exceeds it scale-up the ECS tasks.当一定数量的任务超过它时,扩大 ECS 任务。 And it scale-down when task in queue go below certain numbers.当队列 go 中的任务低于特定数字时,它会按比例缩小。

However, as there is no LifeCycleHook feature for ECS task, during the time of scale-down the ECS tasks are shut down while the processing is still running.但是,由于 ECS 任务没有 LifeCycleHook 功能,因此在缩减期间,ECS 任务会在处理仍在运行时关闭。 And it's not possible to delay the task termination due to the lack of LifeCycleHook.由于缺少 LifeCycleHook,因此无法延迟任务终止。

According to our specification, we can't use the timeout feature, as we don't know earlier how much time it will take to finish the job.根据我们的规范,我们不能使用超时功能,因为我们之前不知道完成这项工作需要多长时间。

Please suggest how to solve the problem.请建议如何解决问题。

There is no general solution to this problem, especially if you don't want to use timeout.这个问题没有通用的解决方案,特别是如果您不想使用超时。 In fact there is long lasting, still open, github issue dedicated to this:事实上,有一个持久的、仍然开放的 github 问题专门用于此:

You could somehow control this through running your services on EC2 (EC2 scale-in protection), not Fargate.您可以通过在 EC2(EC2 扩展保护)而不是 Fargate 上运行服务来以某种方式控制这一点。 So either you have to re-architect your solution, or manually scale-out and in your service.因此,要么您必须重新构建您的解决方案,要么手动向外扩展并在您的服务中使用。

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

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