Let's say I have a server with 2 CPU cores, then I launch 2 NodeJS apps. Since NodeJS is single-threaded, will those two nodeJS apps run on different cores or will they run on the same core?
For further information, I'd like to scale up my Socket.IO server. So I want to run two instances of this Socket.IO server without clustering. I worried even if I launched two instances of them it won't utilize all the cores.
CodePudding user response:
will those two nodeJS apps run on different cores or will they run on the same core?
You're running two different processes. Scheduling where they run is up to your operating system. Yes, they'll use different cores. It's no different than multiple instances of any other executable.
Since NodeJS is single-threaded...
This is a bit of a myth, and not applicable for most Node.js applications. Your JavaScript runs single-threaded, sure, but all of the I/O and everything in the native modules can be multithreaded.
You can test this yourself easily, to get an idea for what the load looks like for your specific application. It all depends on what you're doing, specifically.