clustermodule I started utilizing yesterday to solve the scaling issue that exists outside of the box. In doing this research I came across a few solutions:
pm2you will need to install via:
npm install pm2 -g
pm2has a built in clustering option, the code written last night has no purpose anymore, but thankfully I abstracted out the actual "worker" code to it's own
worker.jsfile. That being said, all you have to do to have
node.jscode for all of your cpu cores is:
From there you should see
pm2 start worker.js -i 0
pm2kicking off a process for each of your cpu cores available. In my case, my 2014 Razer Blade laptop has 4 cores/8 threads so it kicked off 8 processes. If you wanted to limit the number of processes you can specify a different number instead of 0.
pm2is the ability to monitor the processes with a simple:
Which on my machine produced:
command to stop all of the processes.
pm2 stop all
node.js. I am excited to keep deep diving into pm2 tomorrow. An issue I was running into on Windows 10 (need to try it on Linux) is that only one process was being hit at ~65% according to
pm2. Whether this is a Windows specific issue, a problem with pm2 or a problem with my code I need to further dive into.