使用不同的端口在一台主机中基于相同任务定义运行多个ECS任务 [英] Running multiple ECS tasks based on same task definitions in one host, using different ports

查看:59
本文介绍了使用不同的端口在一台主机中基于相同任务定义运行多个ECS任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ecs任务定义.上述任务定义的多个任务可以在多个端口上的一个EC2实例上运行吗?

I have one ecs task definition. Can multiple tasks of the above task definition can run on one EC2 instance on several ports ?

我已经在多个ec2实例上运行了多个任务.我想减少资源消耗.因为一个EC2实例具有足够的资源来运行多个任务.是否可以在一个EC2实例的不同端口上多次运行同一任务?

I have already have running several tasks running on several ec2 instances. I want to reduce the consumption of resources. As one EC2 instance has more than enough resources to run several tasks. Is it possible to run same task several times on different ports on one EC2 instance ?

推荐答案

是的,自2016年以来,ECS对此提供了很好的支持.您可以在容器定义中将主机端口保留为空,这将导致随机端口为选择用于您的容器.结果,同一任务定义的更多实例可以在一个ECS实例上运行.

Yes, ECS has very good support for this since 2016. You can leave the host port empty in the container definition, this will result in a random port to be chosen for your container. As a result, more instances of the same task definition can run on one ECS instance.

您可以将ECS服务与Application Load Balancer组合配置,以便在启动新任务时将端口号注册到关联的目标组中.这样,您就不必处理随机端口.

You can configure your ECS service in combination with an Application Load Balancer so that when it starts a new task, it will register the port number in the associated target group. This way you never have to deal with the random port.

如果您通过AWS控制台设置服务,则配置非常简单.

If you setup your service via the AWS console, configuration is pretty straightforward.

这篇关于使用不同的端口在一台主机中基于相同任务定义运行多个ECS任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆