Skip to content

Disadvantages of using cluster api without any listening sockets #970

Closed
@pimlie

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions