P
P
PAJCH2015-09-28 22:15:48
JavaScript
PAJCH, 2015-09-28 22:15:48

How does the cluster module work in nodejs?

Please explain the essence of the cluster module in nodejs, in two or three words .. I'm a beginner

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Timur Shemsedinov, 2015-09-28
@PAJCH

Without cluster, the node runs on 1 core, new processes are created for scaling via cluster.fork(); Each of the processes can find out if it is a master or a child through cluster.isMaster and cluster.isWorker. Messages (events) and sockets (socket descriptors) can be passed between processes. Thus, tcp or http sockets are received by the main process, and sent to one of the child processes for processing. This is in a nutshell, everything is well written in the docs https://nodejs.org/api/cluster.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question