简体   繁体   English

同一实例主机上的多个Amazon ECS任务

[英]Several Amazon ECS tasks on the same instance host

Say I have an autoscaling group with initial number of 2 instances. 假设我有一个初始实例数为2的自动扩展组。 Assume that instances of this autoscaling group would be of the same type (hence the same amount of memory and CPU). 假设此自动伸缩组的实例将具有相同的类型(因此具有相同的内存和CPU数量)。 The maximum number of instances isn't relevant in this case. 在这种情况下,最大实例数无关紧要。 Also I have an ELB which load-balancing load among instances of this group. 我也有一个ELB,可以平衡该组实例之间的负载。 Besides this, instances of this autoscaling group are members of some fresh ECS cluster I've created earlier. 除此之外,此自动扩展组的实例是我之前创建的一些新ECS集群的成员。 There is only one task definition in this case with only one container which would use 512Mb of RAM. 在这种情况下,只有一个任务定义,只有一个容器使用512Mb的RAM。 Also this container requires port mapping from host's 80 to container's 5000. 此外,此容器还要求端口从主机80映射到容器5000。

Say I've spun up this autoscaling group and 2 initial instances are now ready to be used. 假设我已经启动了这个自动伸缩组,现在可以使用2个初始实例。 Then I'm trying to spawn a service of 4 tasks based on the aforementioned task definition. 然后,我尝试根据上述任务定义生成包含4个任务的服务。 Imagine that this tasks would perfectly fit this 2 instances if they were placed by two (if the hosts had 1Gb of RAM each). 想象一下,如果两个任务放在一起(如果主机每个都有1Gb RAM),则此任务将完全适合这两个实例。

Would this setup even be legitimate? 此设置甚至合法吗? If so then what would happen with port mappings because there would be 2 identical containers on one host? 如果是这样,那么端口映射会发生什么,因为在一台主机上会有​​2个相同的容器?

You would forward the 5000 to different instance ports (since you can't bind 80 multiple times). 您可以将5000转发到不同的实例端口(因为您不能多次绑定80)。

You could then use an ELB to map across the ports. 然后,您可以使用ELB在端口之间进行映射。 this post answers the specifics . 这篇文章回答了具体问题

You'd want to standardize the ports of service 1 across the cluster so that you could bind an ELB to it. 您需要标准化集群中服务1的端口,以便可以将ELB绑定到该端口。 Ie. IE浏览器。 ELB port 80 can't be mapped to 5000 and 5001. So port 5000 would be forwarded on both instances. ELB端口80无法映射到5000和5001。因此,端口5000将在两个实例上转发。

在此处输入图片说明

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

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