Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS ELB when target (backend) applications runs on multiple ports of the same EC2

I have 2 instances of the same web application running on port 8080 and 8081. I need to load balance using ALB/CLB. This used to be a simple thing in good old apache web server.The requirement is to load balance the instances below

Instance 1 Web App 1 Port 8080

Instance 1 Web App 2 Port 8081

Instance 2 Web App 1 Port 8080

Instance 2 Web App 2 Port 8081

I am not able to do this with ALB. I have tried creating 2 target groups, one for port 8080 and the other for port 8081. But in the listener rule, I can send the requests to different target groups based the path. But that is not going to load balance the whole site as such. Refer the screenshot

enter image description here

What are my options here ?

Thanks in advance

like image 986
Sujith Babu Avatar asked Oct 23 '25 12:10

Sujith Babu


1 Answers

In an ALB, create one target group, adding each instance to the group, twice -- once for each port.

You can register each EC2 instance or IP address with the same target group multiple times using different ports, which enables the load balancer to route requests to microservices.

https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html#registered-targets

Note that this assumes what you are calling "app 1" and "app 2" are in fact the same application, just two different processes, as you described.

like image 155
Michael - sqlbot Avatar answered Oct 26 '25 07:10

Michael - sqlbot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!