2

I am new to Node.js but I have an extensive Python background, and I was wondering how I would achieve the same outcome on Node.js as I would with Python Multiprocessing Pools. I have seen people do this without any outside libraries, so it leads me to believe that it is something native to Node. Every time I try to research this topic, I get some response about Clustering, which is effective on the server side of Node.js, but I am using Node through my command line, for desktop apps. Thanks to all!

Michael
  • 169
  • 1
  • 2
  • 14
  • read about `cluster` module here https://nodejs.org/dist/latest-v8.x/docs/api/cluster.html , there are also some packages that have nice features, not very familiar with python myself. – Gntem Dec 27 '17 at 19:48
  • cluster is not useful in desktop nodejs – Michael Dec 27 '17 at 22:58
  • i don't think you understand what cluster does in node.js.. `A single instance of Node.js runs in a single thread. To take advantage of multi-core systems, the user will sometimes want to launch a cluster of Node.js processes to handle the load.` its native to node.js and its as close it can get to multiprocessing.. – Gntem Dec 28 '17 at 17:08

1 Answers1

0

Node.js base architecture design is one-threaded, but cluster module provides a neat approach for taking advantage of multi-core systems for creating TCP and HTTP servers (what you may mean by referring to as server side of Node.js).
Cluster module itself, uses child processes module to provide its functionality.

Child processes module provides functionalities for opening (spawning) other processes and communicating with them. (see this article for more information on this module's functionalities)

Given above information you have these options for doing multiprocess operations in Node.js:

mahdavipanah
  • 600
  • 5
  • 21