We have a usecase where we want to make an http call to a particular EC2 instance behind an ALB. I tried finding solution for this on AWS docs but was unable to find one. Can anyone suggest me how i can achieve this?
Why i want to do this?
So, Basically we have a service which is scaled out using ASG and we have a load balancer to balance the load of various clients that will connect to it. This is a persistent long running connection.
Now, we also have another service which wants to send request to the instance where a particular client is connected.
Any help is much appreciated. Thanks!
Is your question how to ensure that a client is always connecting to the same backend-instance? If yes, then Sticky Sessions are your answer.
If you want to be able to address and particular instance in the backend that's not possible. A big part of the reason to use a Load Balancer is to make the number of backend instances an implementation detail that's not exposed to the client.
In principle you could create a DNS-Record for each EC2-Instance, route that to the ALB and then do Host-based-routing to map each of them to a particular instance, but in that case you might as well expose the instances directly (unless you need encryption and stuff like that).