Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Application Load Balancer for an ECS Service with multiple port mappings?

I want to be able to use an ALB (ELBv2) to route traffic to multiple port mappings that are exposed by a task of a given service.

Example --

Service A is composed of 1 Task running with Task Definition B.

Task Definition B has one 'Container' which internally runs two daemons on two different port numbers (port 8000 and port 9000, both TCP). Thus, Task Definition B has two ports that need to be mapped to the ALB.

I'm not too worried about the ports that the ALB exposes (they don't have to be 8000 and 9000, but will help if they were).

  • my-lb-dns.com:8000 -> myservice:8000
  • my-lb-dns.com:9000 -> myservice:9000

Any ideas on how to create multiple listeners and target groups to achieve this? Nothing in the Console UI is allowing me to do this, and the API has not been very helpful either.

like image 541
ultimoo Avatar asked Oct 12 '16 04:10

ultimoo


People also ask

How load balancer works with ECS?

Your Amazon ECS service can optionally be configured to use Elastic Load Balancing to distribute traffic evenly across the tasks in your service. When you use tasks sets, all the tasks in the set must all be configured to use Elastic Load Balancing or to not use Elastic Load Balancing.

Can application Load Balancers span across multiple regions?

A: No. For each associated subnet a Network Load Balancer is in, the Network Load Balancer can only support a single public/internet facing IP address.

What is the default port used by the load balancer created by the ECS service?

Load Balancer: an Application Load Balancer (the default type), with an associated security group. Load Balancer Listener: listening on port 80 for HTTP traffic, this will forward requests onto the target group as its default behaviour.


1 Answers

After speaking with AWS support, it appears that the ECS service is geared toward micro-services that are expected to expose only one port. Having an ECS Service use an Application Load Balancer to map two or more ports isn't supported.

Of course, an additional Load Balancer can be manually added by configuring the appropriate target groups etc., but ECS will not automatically update the configuration when services are updated or scaled up, and also when the underlying container instances change.

like image 114
ultimoo Avatar answered Oct 01 '22 19:10

ultimoo