2

Am I able to make Node.JS multi-machine cluster with native cluster module or this module can be used to split work just between CPU threads on same machine?

1
  • 2
    This is not possible, sounds like you’re looking for something like Kubermetes or NGINX like @shubh said Commented Dec 11, 2019 at 12:42

1 Answer 1

2

As per docs

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.

So obviously it will work on the same machine .

But in your scenario what you can do is distribute requests to different machines using Any Proxy server Like Nginx

It distributes the request ,to the multiple backend machines. Also see Nginx Load Balancing.

http {
    upstream backend {
        server backend1.example.com weight=5; // machine 2 ip
        server backend2.example.com; // machine 1 ip
        server 192.0.0.1 backup; // machine 3 ip
    }
}

And in those machine you can create clusters or better use any Cluster Manager like pm2

Sign up to request clarification or add additional context in comments.

1 Comment

I was more thinking about doing some kind of distributd system without SPOF like proxy with this module, but this answer clearly explains why cluster module is not capable of multi server cluster. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.