EC2 上的自动缩放 Web 服务 运行:将 Auto Scaling 启动配置与自定义 AMI 一起使用还是使用 ECS?

Autoscaled web service running on EC2: use Auto Scaling Launch Config with custom AMI or use ECS?

在我看来,有两种替代方法可以在 ELB 后面的 EC2 实例上使用自动缩放的 Web 服务 运行:

1) 创建一个 Auto Scaling 启动配置,指定我的自定义 AMI 的映像 ID(以及要使用的实例类型)。然后,当触发 Auto Scaling 触发器时,它会简单地使用该 AMI 启动新的 EC2 实例。

2) 改用 ELB 和 ECS,因为 ECS 似乎有自己的 Auto Scaling 功能。

什么情况下使用ECS比较好?

这两个选项并不相互排斥。首先回答您的最后一个问题,您在 运行 容器化应用程序时使用 ECS。您可以使用 ECS 中的 Service AutoScaling 服务扩展这些应用程序。当您 运行 缺少处理传入请求的资源时,这将帮助您调出额外的容器。

这与使用启动配置扩展 EC2 实例不同。当您 运行 资源不足时,您将需要额外的实例才能在 ECS 集群中启动新容器。顺便说一句,您应该始终使用启动配置,以便将新的 EC2 实例引入绑定到您的 ECS 集群的 AutoScaling 组中,因为它使一切变得更加容易。参见示例 this tutorial

至于 ELB,在 ECS 中你实际上最好使用 ALB. In containerized applications, you need to map their exposed ports to random ports in the host machine. This makes the registration with the load balance a lot more complicated. However, ALB is integrated with ECS so that, whenever you launch a new task, the ECS Service running the task requests a registration of the task as a target for the ALB (see this link 以获得更详细的解释)。它代表您处理所有事情。