0

Before going to production, we want to make sure that this is an "as expected behavior".

I have conducted an experiment by laucnhing 4 child processes using a PM2 cluster (I have 4 cores on my machine). Which means there were 4 websocket processes running...

Then on the client I created multiple sockets, and sent many messages to the server. One thing I didn't expect was that Node was able to figure out what child process the socket belonged to, meaning that every message sent by the client was console logged by the correct child process.

It seems like the main worker in the cluster keeps track of what sockets belong where.

So is this managed by Nodejs internally by the "cluster" module? Also is this ok to use in production?


P.S. for websockets we use "ws" module for Nodejs

sofasurfa
  • 21
  • 4

1 Answers1

1

I aksed the same question on github. And got an answer... Also please look into using ClusterWs - it's awesome!

https://github.com/ClusterWS/ClusterWS/issues/143

sofasurfa
  • 21
  • 4