1
votes

I want to set up a cluster of Node.js services with a Load Balancer in front of them (which for some reasons can't have sticky sessions).

Let's imaging I have two Nodes, and client (browser, for instance, using socket.io) sends wss:// request, and first Node gets it from LB, then it sends back to the client 'HTTP/1.1 101 Web Socket Protocol Handshake' response.

  1. Will client and server afterwards use the same TCP connection for sending frames that was used for the initial client request? Or a new TCP connection will be established which might potentially be forwarded to the second Node by LB?

  2. In case of using socket.io, it might still fallback and actually send long polling over http before WebSocket connection is established for performance. Are those polling requests can end up on different backend nodes?

1

1 Answers

1
votes
  1. Yes, WebSockets use the same TCP/IP connection that was used during the HTTP handshake.

  2. Yes, long polling might be routed to different nodes, unless specifically set up to avoid doing so (which I wouldn't recommend, as it signals a scaling weakness in the architecture).