I am using Express js and Node-cluster for taking the advantage of clustering I am also using PM2 for process and memory management. For a single machine, it is working fine, bu
Horizontal scaling for node can be done in multiple ways :
npm install http-proxy
var proxyServer = require('http-proxy');
var port = parseInt(process.argv[2]);
var servers = [
{
host: "localhost",
port: 8081
},
{
host: "localhost",
port: 8080
}
];
proxyServer.createServer(function (req, res, proxy) {
var target = servers.shift();
proxy.proxyRequest(req, res, target);
servers.push(target);
}).listen(port);
nginx
for more detail please check the below URL Horizontal scaling for node js