I
I
ILE2016-03-21 14:54:54
JavaScript
ILE, 2016-03-21 14:54:54

Interaction between master process and workers in nodejs?

Good evening!
I wanted to ask about messaging between master and workers in NodeJS.
Why do I need it?
For example, I have a chat on websockets, and in multi-threaded mode, for example with the cluster module, clients are lost and this is obvious.
I don't want to use Redis or a similar database, but would like to do it with the built-in NodeJS tools.
NodeJS has the ability to communicate between processes.
ACTUAL QUESTION:
When a client connects, the current worker sends the socket object of the client to the master, and the master throws this client into its global object, and then sends this object back to the current worker. And if I have 10k clients online, then when other clients connect, a very large object with 10k clients is sent, is this bad? Is it better than using for example Redis?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Belyaev, 2016-03-21
-Salim @ILE-Salim

redis with its pub / sub mechanism will be simpler, faster and more convenient
. And so, communication between the worker and the master is
the simplest possible - this is through the built-in ipc in child_process / cluster - slow, but works without unnecessary problems
, a more complicated option - tcp / upd / unix socket

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question