0

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!

1 Answers1

0

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

Maurice
  • 11,482
  • 2
  • 25
  • 45
  • Thanks for your answer. Actually, my question was after the client connects to a particular instance. We have a registry which will store the mapping of client to instance. Now post client is connected we want to route all the communications from backend service to that particular instance. – Mayank Gupta May 17 '21 at 09:18
  • In that case you will have to do a lookup and connect manually, that's not something supported through the Load Balancers. As I said, they're about abstraction. – Maurice May 17 '21 at 09:42
  • Got it. Thank you! – Mayank Gupta May 17 '21 at 11:36