简体   繁体   English

如何为使用计划任务且无服务的 ECS 集群设置自动伸缩?

[英]How to set up autoscaling for ECS cluster that uses scheduled tasks and no service?

I have an ECS cluster which i have an ec2 instance tied to and a scheduled task set to run daily using the 'Scheduled Tasks' functionality on the ECS dashboard.我有一个 ECS 集群,我有一个绑定的 ec2 实例和一个计划任务集,使用 ECS 仪表板上的“计划任务”功能每天运行。

This task runs aa bunch of containers that are each relatively expensive in memory, and this is compounded even more so with all the containers running at once.该任务运行一堆容器,每个容器在 memory 中都相对昂贵,而且所有容器同时运行时更是如此。

I do not currently have a service set up for the ECS cluster and it is my understanding that for my goals, running a set task on some interval, a service would not be used.我目前没有为 ECS 集群设置服务,据我了解,为了我的目标,在某个时间间隔运行设置的任务,不会使用服务。

AWS's definition of a service in there ECS docs says: AWS 在 ECS 文档中对服务的定义说:

An Amazon ECS service enables you to run and maintain a specified number of instances of a task definition simultaneously in an Amazon ECS cluster.

Since this is not what I want;因为这不是我想要的; instead i need to just run a task on some scheduled interval i gather i do not need an service tied to my ECS cluster.相反,我只需要按我收集到的某个预定时间间隔运行一项任务,我不需要绑定到我的 ECS 集群的服务。

My question is on how to set up autoscaling for my scheduled tasks?我的问题是如何为我的计划任务设置自动缩放? The only references i can find to auto scaling within an ECS cluster are to do with creating ecs services that auto scale - which again, is not what I want (at least from how i understand ecs services to work).我能找到的关于 ECS 集群中自动扩展的唯一参考是创建自动扩展的 ecs 服务——这又不是我想要的(至少从我理解 ecs 服务的工作方式来看)。

What I need is for my ec2 instances to auto scale with my scheduled task running, allocating more resources as need for the task to run.我需要的是让我的 ec2 实例在我的计划任务运行时自动扩展,根据需要分配更多资源以运行任务。 Would I just need to set up auto scaling on the specific ec2 instance the ecs cluster is tied to from within the ec2 dashboard or is there some other way to do this from ECS directly?我是否只需要在 ec2 仪表板中绑定 ecs 集群的特定 ec2 实例上设置自动缩放,还是有其他方法可以直接从 ECS 执行此操作?

I want;我想; instead, I need to just run a task on some scheduled interval I gather I do not need a service tied to my ECS cluster.相反,我只需要按我收集到的某个预定时间间隔运行一项任务,我不需要绑定到我的 ECS 集群的服务。

For the above use case better to use fargate and you will not maintain or worry about auto-scaling scheduling , all you need to setup schedule task and AWS will take care of memory and other resources required for your task plus you will only pay for the resources that were used by you ECS task , unlike EC2 type task where you pay for the container instance.对于上述用例更好地使用fargate并且您无需维护或担心自动扩展调度,您只需要设置调度任务,AWS 将负责您的任务所需的 memory 和其他资源,您只需支付您的 ECS 任务使用的资源,与您为容器实例付费的 EC2 类型任务不同。

AWS Fargate is a serverless compute engine for containers that works with both Amazon Elastic Container Service (ECS) and Amazon Elastic Kubernetes Service (EKS). AWS Fargate 是适用于容器的无服务器计算引擎,可与 Amazon Elastic Container Service (ECS) 和 Amazon Elastic Kubernetes Service (EKS) 配合使用。 Fargate makes it easy for you to focus on building your applications. Fargate 让您可以轻松专注于构建应用程序。 Fargate removes the need to provision and manage servers, lets you specify and pay for resources per application , and improves security through application isolation by design. Fargate 消除了配置和管理服务器的需要,允许您指定每个应用程序的资源并为其付费,并通过设计的应用程序隔离提高安全性。

aws fargate aws 法盖特

Create a cloud watch rule base on some schedule that will trigger the task, make sure that the container exit once it completes the job, fargate will automatically stop the container.根据触发任务的计划创建云监视规则库,确保容器在完成作业后退出,fargate 将自动停止容器。

在此处输入图像描述

在此处输入图像描述

cloudwatch-event-rule-to-invoke-an-ecs-task cloudwatch-event-rule-to-invoke-an-ecs-task

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

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