Amazon EC2 容器服务中的 REPLICA 和 DAEMON 服务类型有什么区别?

What is difference between REPLICA and DAEMON service type in Amazon EC2 Container Service?

当我在 Amazon EC2 Container Service 中创建服务时,服务类型有 2 个选项:REPLICA 和 DAEMON。

它们之间的确切区别是什么?

Replica services place and maintain a desired number of tasks across your cluster. Daemon services place and maintain one copy of your task for each container instance

您的 ECS 集群很可能存在于多个 EC2 实例(= 容器实例)中。

根据 AWS documentation

Replica: The replica scheduling strategy places and maintains the desired number of tasks across your cluster. By default, the service scheduler spreads tasks across Availability Zones. You can use task placement strategies and constraints to customize task placement decisions

Daemon: The daemon scheduling strategy deploys exactly one task on each active container instance that meets all of the task placement constraints that you specify in your cluster. When using this strategy, there is no need to specify a desired number of tasks, a task placement strategy, or use Service Auto Scaling policies.

这意味着,如果您有一个包含三个 EC2 实例的 ECS 集群,并且您想要启动一个包含四个任务的新服务,则会发生以下情况:

  • Replica:您的四个任务将开始随机分布在您的容器实例中。这可以是一个实例上的所有四个或任何其他随机分布。这是普通微服务的用例。

  • 守护进程:对于守护进程,您无需指定要处理多少个任务运行。守护程序服务会根据您拥有的 EC2 实例数量自动扩展。在这种情况下,三个。守护进程任务是构建微服务时使用的一种模式,其中将任务部署到集群中的每个实例上,以提供常见的支持功能,如日志记录、监控或备份应用程序代码中的任务运行。