load-balancinggcloudsession-affinity

Gcloud load balancing to the same host for two TCP connections


I'm using GCP like in the following schema:

  1. TCP balancer -> backend-service -> MIG(my app) with auto scaling.

"My app" accepts commands on a TCP port (A) and sends notifications on another TCP port(B) for subscriber.

I'm running my tests against TCP LB's IP - my tests connect to port B on a startup(i.e. one of instances of "my app") and also my tests make a connection to port A for each test.

i.e. I've faced with a case when port A and port B are terminated/connected to different hosts.

I am not sure how to circumvent this case.


Solution

  • I have mitigated the issue using --session-affinity=CLIENT_IP for backend-services configuration, I.e. all connections from one IP are directed to the same target.