Reputation: 580
I have the following stack (deployed by CloudFormation):
I am going to create an autoscaling configuration for the ECS service to scale up and down based on SQS metric.
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? 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?
Upvotes: 1
Views: 757
Reputation: 238209
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.
Use ECS service discovery. 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. After each timeout, the IPs will be in different order. For this lambda would also be in a vpc and use private url associated with the ECS service to invoke your service.
Upvotes: 2