简体   繁体   English

具有多个任务的 AWS ECS 服务需要负载均衡器

[英]AWS ECS service with multiple task need load balancer

I have the following stack (deployed by CloudFormation):我有以下堆栈(由 CloudFormation 部署):

  1. SQS queue that trigger a lambda function触发 lambda function 的 SQS 队列
  2. The lambda function is calling an ECS service (by http post request - which is an express.js server) lambda function 正在调用 ECS 服务(通过 http 发布请求 - 这是 express.js 服务器)

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.我认为有两种方法可以解决这个问题。

  1. 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。

  2. 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.

相关问题 使用应用程序负载均衡器在aws ECS上进行服务发现 - Service discovery on aws ECS with Application Load Balancer Terraform - 如何在多个 AWS ecs_service 资源之间使用相同的负载均衡器? - Terraform - how to use the same load balancer between multiple AWS ecs_service resources? ECS 服务的 AWS 网络负载均衡器运行状况检查失败 - AWS Network load balancer health check is failing for ECS service 结合使用AWS ECS Service发现和Application Load Balancer - Using AWS ECS Service discovery with Application Load Balancer 如何使用 ansible 将负载均衡器添加到 aws ecs 服务 - How to add load balancer to aws ecs service with ansible 带有ECS的AWS Application Load Balancer - AWS Application Load Balancer with ECS 如何将Application Load Balancer用于具有多个端口映射的ECS服务? - How to use Application Load Balancer for an ECS Service with multiple port mappings? 使用AWS中的应用程序负载均衡器进行ECS容器路由 - ECS container routing with an application load balancer in AWS 动态端口和 AWS Applocation 负载均衡器和 ECS - Dynamic ports and AWS Applocation Load balancer and ECS Terraform - 无法在 AWS ECS 中使用负载均衡器 - Terraform - cannot use Load Balancer in AWS ECS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM