<p>Clients are connecting to API gateway server through websocket connection. This server just orchestrates swarm of cloud functions, that are handling all of the data requesting and transforming. Server is statefull - it holds essential session data, which is defining, for example, what cloud functions are allowed to be requested by a given user.</p>

<p>This server doesn't use socket to broadcast data, so socket connections are not interacting between each other, and will not be doing this. So, all it needs to handle is single-client-to-server communication.</p>

<p>What will happen if i'll create bunch of replicas and put load balancer in front of all of them (like regular horizontal scaling)? If a user got connected to certain server instance, then his connection will stick there? or it will be switching between instances by load balancer?</p>

<p>There is a parameter available for load balancer that allows you to do what you are looking for: <a href="https://cloud.google.com/compute/docs/load-balancing/http/backend-service#backend_service_components" rel="nofollow noreferrer">Session affinity</a>. </p>

<p>"Session affinity if set attempts to send all network request from the same client to the same virtual machine instance."</p>

<p>Actually even if it seems to be related to load balancer you set it while creating <a href="https://cloud.google.com/compute/docs/load-balancing/network/target-pools" rel="nofollow noreferrer">target pools</a> and/or <a href="https://cloud.google.com/compute/docs/load-balancing/http/backend-service#backend_service_components" rel="nofollow noreferrer">backends</a>. You should check if this solution can be applied to your particular configuration.</p>
