Sridar,
On 7/28/21 20:16, Sridhar Rao wrote:
We are using the tomcat8.5 app nodes behind an Nginx Load Balancer.
Whenever the LB takes out an app node from the pool, "existing" WebSocket
connections are still staying with the app node. Also, if a new app node is
added to the pool, WS connections are not load balanced as they are
persistent. In general, wondering what are some of the mechanisms/tools are
employed to handle WebSocket load balancing issues.
Websocket is a connection-oriented protocol negotiated through a
connectionless protocol (HTTP), and you end up with a persistent
connection from client to server. Compare this to the (very!) old style
of connecting a telephone call between two distant callers by making a
series of physical connections such that you have one continuous circuit
between the caller and the receiver. (That was before switching was
introduced.)
Anyhow, once the connection has been established, what you describe is
expected behavior: only HTTP can be load-balanced. Once the Websocket
connection has been established, there is no way to "migrate" the
connection to another node.
What you *can* do is terminate the connection and establish a new one,
which will indeed be load-balanced as you expect.
Note that this may be awkward for your application.
One of the easiest possible things to do would be to implement a
timed-termination of the connection on the client and/or the server so
that Webocket connections never last more than e.g. 1 minute so your
load-balancing becomes effective again.
Another possibility would be to think about why you are using Websocket
in a way that would *require* load-balancing.
-chris
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org