Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Good way to use with cluster in multi-core server?

Good way to use 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 supports multi-core system?

Is only for single core use?

Problem courtesy of: user482594


You could use as normal but with a redis store in the background. It will also support multiple instances on without any external library. It even supports rooms over multiple instances.

Link to how to set up with redis: Using Multiples Nodes/Processes with

Solution courtesy of: Martin


View additional discussion.

This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Good way to use with cluster in multi-core server?


Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription