Good way to use socket.io with cluster in multi-core server?
Now, I wanted to scale my application vertically, by enabling it to run on multi-core system using
cluster module in nodejs.
Everything in my application stores data in Redis, therefore, there isn't a problem dealing with some basic data & sessions.
However, when I spawn multiple worker processes using cluster, it seems that each worker has its own socket handling.
For example, lets assume there is a chat room called 'guest' room.
User A and user B connects to the room, and they are distributed to the different worker process.
Since they are in different processs and these processes do not share sockets listener, there is no way for user A and user B to talk to each other.
What is a good approach to solve this problem? Does socket.io supports multi-core system?
Is socket.io only for single core use?
You could use socket.io as normal but with a redis store in the background. It will also support multiple instances on socket.io without any external library. It even supports rooms over multiple instances.
Link to how to set up socket.io with redis: Using Multiples Nodes/Processes with socket.io