[英]AWS ECS service with multiple task need load balancer
I have the following stack (deployed by CloudFormation):我有以下堆栈(由 CloudFormation 部署):
I am going to create an autoscaling configuration for the ECS service to scale up and down based on SQS metric.我将为 ECS 服务创建一个自动扩展配置,以根据 SQS 指标进行扩展和缩减。
If there will be multiple tasks in the service (means there were a lot of SQS messages) how will the service manage the calls to the tasks?如果服务中有多个任务(意味着有很多 SQS 消息),服务将如何管理对任务的调用? will I need to add a load balancer for the service?
我需要为服务添加负载均衡器吗? or the service know how to balance it between the tasks without load balancer?
或者服务知道如何在没有负载平衡器的任务之间平衡它?
I think there are two ways to deal with this.我认为有两种方法可以解决这个问题。
Use load balancer as you pointed out.正如您指出的那样使用负载平衡器。 It can be internal load balancer.
它可以是内部负载均衡器。 In this case, lambda will be associated with a VPC and will call the balancer's private dns.
在这种情况下,lambda 将与 VPC 关联,并将调用平衡器的私有 dns。
Use ECS service discovery .使用ECS 服务发现。 This can also server as sort-of load balancer, though not as feature reach as regular balancer.
这也可以作为某种负载平衡器服务,尽管不像常规平衡器那样具有功能。 The reason is that the private url associated with the service will return multiple IPs of its tasks, and the distribution of incoming requests is based on DNS cache timeouts.
原因是与服务关联的私有 url 将返回其任务的多个 IP,并且传入请求的分布基于 DNS 缓存超时。 After each timeout, the IPs will be in different order.
每次超时后,IP 将按不同的顺序排列。 For this lambda would also be in a vpc and use private url associated with the ECS service to invoke your service.
对于此 lambda 也将位于 vpc 中并使用与 ECS 服务关联的私有 url 来调用您的服务。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.