I am wanting to scale on a multi-core machine. Using the cluster
library is an option, but I would like to know if I can do this a more simple way: by simply running multiple servers.
So what I want to know is this: does Node.js automatically spread servers over multiple cores. So if I have 5 cores, and 5 servers, would each server run on each core.
If so, would this be a viable way of scaling on a multi-core machine?
Indeed, just running multiple instances of a node app, will use multiple processes.
But one note, the cluster option has one slight advantage, and that's if your creating something that listens on a TcpIP port, the cluster can share a single IP port,.. eg. If say you was running a webserver on port 80, you could use all cores that run on port 80..
What I tend to do though, is run a reverse proxy on Port 80, and have other processes running on different ports. IOW: The cluster option is great for creating a reverse proxy.. :)
The advantage of the above is that a reverse proxy does not really need to keep state, you can have it do the SSL too all using cluster. This leaves your node apps, so it can keep state, eg. Cached responses in memory etc. Big advantage of node is that of in-process requests, no special ipc needed here.