简体   繁体   中英

Node.js changing app to work with cluster module

I'm gonna change my app to work with cluster module, and wondering how it will change my life. App is an chat. It is about sending and reciving messages from clients to server app and from server app to client. And some others stuff like every X seconds combine users from array of them(singles) into pairs.

And I wonder if some users will be logged in one worker, and some others will be logged in other worker, can app combine them into pairs when I get them from array of sockets in socket.io library?

I'm new to clusters in Node.js and try to make image of it.

EDIT:

I found it: https://github.com/fent/socket.io-clusterhub

This is library for easly using cluster with socket.io. And now I wonder if it work well or not. Because it seems be too easy and I am distrustful. I can test it, but not with a lot of users. I don't know what will happen then. So I'd like to ask if someone knows this library clusterhub (link above)

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. Works like a charm!

Link to how to set up socket.io with redis: https://github.com/LearnBoost/socket.io/wiki/Configuring-Socket.IO

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM