I have a Node.js app that I want to run on a multi core (2CPU * 2Cores = 4Cores) server. After reading through a bunch of Stack Overflow threads on this topic, I have decided to start 4 separate node instances on 4 different ports and use Nginx to load balance among them. I decided to use this approach over node cluster.
Here are my questions that I'm trying to answer:
Is there any difference in how one would start 4 node instances on a 2cpu * 2cores/cpu = 4 core server vs. 1cpu * 4cores/cpu = 4core server. I don't think there is any difference, but just wanted to confirm.
I have a conf file to start my service. This conf file is actually a script that resides in /etc/init and starts my Node app. Should I start the 4 instances from this 1 conf file or should I create 4 conf file and start one instance per conf file?
Again, I feel the latter approach is better, but wanted to confirm it.
Why have you decided to:
manually start n processes when there's a cluster module that does that for you?
If you start n different processes you'll need to listen to n different ports.
If you use the cluster module you don't need any load balancer because this job is done internally and the n workers will listen to the same port. If a worker dies you get a notification and basically you can manage them easily.
All the workers can open/read/write/close the same file, you don't need n config files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With