Closed lay3r closed 8 months ago
Pm2 has nicer logging and management features. But aside from that there's not much reason
Then you have to look at the logs of each cluster
On the other hand, pm2 will automatically restart the cluster, got you
https://socket.io/docs/v4/pm2/
You can pass everything through one port
Right now nginx handles the connections as a gateway and then delegates to the appropriate shard running on separate ports
I can't figure out from your code how a client connects to the same socket session as another client in cluster mode. The roomid is linked to the shard? Because I can't see sticky sessions.
The SHARD parameter is computed from the room name and passed in the URL. Nginx handles directing the traffic to the correct port/instance
What about connecting users to session through redis?
That could probably work too but requires a dependency on Redis
Why are you using pm2 shards and not nodejs cluster?