Disadvantages of using cluster api without any listening sockets #970
Description
I was wondering if there are any major disadvantages of using the Cluster
api to parallelise cpu-bound tasks that don't use/require any listening sockets?
It seems that at the moment the Cluster
api is the only built-in api that can be used for general master/worker setups. Eg it provides all functionalities for creating a master process that delegates jobs to workers, regardless whether those workers are using listening sockets or not. But the documentation only speaks about using the cluster package for clustering connections.
To give a real-life example, currently I am using Cluster
in the nuxt-generate-cluster package. This package provides a cli command to nuxt to generate all dynamic pages using multiple processes. That works great, but it still feels like using the Cluster
api is wrong because the cli command just runs once and doesnt listen for incoming inconnections.
That said, I looked at implementing a master/worker solution myself using child_process
directly but I dont see any benefits for that except for providing me extra work due to possible bugs I introduce.
So what is the general opinion about this? Should you only use the Cluster
api when using listening sockets? Or is it ok to use it without any?
Follow-up questions:
- If it is 👍
Should the docs reflect that it is ok as well? - If it is 👎
Would it be an idea to split the master/worker implementation from Cluster into a separate api which Cluster itself will extend as well?
Activity