简体   繁体   English

自动缩放在ECS中如何工作?

[英]How Autoscaling works in ECS?

I am new to the AWS ECS. 我是AWS ECS的新手。 I am trying to understand Tasks and EC2 instances in the context of ECS Autoscaling. 我正在尝试在ECS自动缩放的上下文中了解Tasks和EC2实例。 I have one Task definition. 我有一个任务定义。 This means that when the Task is created under a service, there will be one EC2 instance. 这意味着在服务下创建任务时,将有一个EC2实例。 Suppose if the service needs to be scaled out through autoscaling. 假设是否需要通过自动扩展来扩展服务。 What happens in this scenario?. 在这种情况下会发生什么? Following are my queries: 以下是我的查询:

1) If I have mentioned 1 EC2 instance in the Cluster setting, what will happen to the autoscaling? 1)如果我在“群集”设置中提到了1个EC2实例,那么自动缩放会发生什么? Will it create a new EC2 instance? 它将创建一个新的EC2实例吗?

2) Can autoscaling create two tasks in the same EC2 instance if there is enough free resource in the 1st EC2 instance? 2)如果第一个EC2实例中有足够的可用资源,自动缩放功能是否可以在同一EC2实例中创建两个任务? If so, What will happen to the port, because now there will be two tasks with the same port mapping. 如果是这样,端口将发生什么,因为现在将有两个具有相同端口映射的任务。

3) This is not related to the Autoscaling, but if I have two different task definition with the same port name. 3)这与自动缩放无关,但是如果我有两个具有相同端口名的不同任务定义。 Does it mean that these tasks will run on two different EC2 instances in the cluster? 这是否意味着这些任务将在集群中的两个不同的EC2实例上运行?

1) If I have mentioned 1 EC2 instance in the Cluster setting, what will happen to the autoscaling? 1)如果我在“群集”设置中提到了1个EC2实例,那么自动缩放会发生什么? Will it create a new EC2 instance? 它将创建一个新的EC2实例吗?
A)If you have configured ec2-autoscaling and scaling policy. A)如果您已配置ec2-autoscaling和scale策略。 Based on that it will create the new ec2 instance. 基于此,它将创建新的ec2实例。

2) Can autoscaling create two tasks in the same EC2 instance if there is enough free resource in the 1st EC2 instance? 2)如果第一个EC2实例中有足够的可用资源,自动缩放功能是否可以在同一EC2实例中创建两个任务? If so, What will happen to the port, because now there will be two tasks with the same port mapping. 如果是这样,端口将发生什么,因为现在将有两个具有相同端口映射的任务。
A)So In ECS, two task of the same service will not run on the same instance because of the High Availability. A)因此在ECS中,由于高可用性,同一服务的两个任务将不会在同一实例上运行。

3) This is not related to the Autoscaling, but if I have two different task definition with the same port name. 3)这与自动缩放无关,但是如果我有两个具有相同端口名的不同任务定义。 Does it mean that these tasks will run on two different EC2 instances in the cluster? 这是否意味着这些任务将在集群中的两个不同的EC2实例上运行?
A) No, if the resource is available it will run on the same or different ec2-instance. A)否,如果资源可用,它将在相同或不同的ec2实例上运行。 Don't worry about the port number as whatever you have defined on task definition that is the container port number and each container run on the same port. 不必担心端口号,因为您在任务定义中定义的就是容器端口号,并且每个容器都在同一端口上运行。 So it can be same across task definition. 因此,跨任务定义可以相同。

Elaborating a bit more on the same containers running on the same host. 对在同一主机上运行的相同容器进行更多详细说明。 No, auto-scaling is not going to launch more of the same containers on the same EC2 instance (unless you have more tasks than EC2 instances, and the tasks don't have overlapping ports). 不,自动缩放不会在同一EC2实例上启动更多相同容器(除非您的任务多于EC2实例,并且这些任务没有重叠的端口)。 If you worry about container ports being the same for copies of the same container then what you can do is to specify dynamic port mapping in your task configuration. 如果您担心容器端口与同一容器的副本相同,那么您可以在任务配置中指定动态端口映射。 Then your containers will receive randomly picked up outbound port from the range of ephemeral ports. 然后,您的容器将从临时端口的范围中随机接收出站端口。 You can place those containers into a single target group which can be targeted by Application Load Balancer. 您可以将这些容器放入一个可由Application Load Balancer定位的目标组。

You can run multiple same/different tasks per cluster and even per EC2 instance but the underlying containers can't share the same outbound port. 您可以在每个集群甚至每个EC2实例上运行多个相同/不同的任务,但是基础容器不能共享相同的出站端口。 If your instance already runs a container which is listening on port 80, launching another container that would listen on the same port will automatically fail. 如果您的实例已经运行了正在侦听端口80的容器,则启动另一个将侦听同一端口的容器将自动失败。 So the answer to your 3rd question is yes, they will need to run on different instances. 因此,第三个问题的答案是肯定的,它们将需要在不同的实例上运行。

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

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