Question

In my company we decided to work with nodejs for our future projects.

For the record, we may have 50 to 100 websites in the same server. It will be small website, ~1000 visitors max in same time for the entire server. We already have ~100 websites running with PHP+Apache on our first server.

My question is simple, what is the best approach ?

Multiple nodejs server :

var http = require('http');
var server = http.createServer(function (rq, rs) {...}); server.listen(3001);
var server = http.createServer(function (rq, rs) {...}); server.listen(3002);
...
var server = http.createServer(function (rq, rs) {...}); server.listen(3999);

Or just one server :

var http = require('http');
var server = http.createServer(function (rq, rs) {...});
server.listen(3001);

Nginx will be used for revers proxy.

Was it helpful?

Solution

100 dynamic sites each with it's own unique business logic? If the answer is no, then likely you need 1 api server (depending on load and reliability requirements - multiple processes / node.js cluster / nginx/elb balancers) + 100 static sites served by nginx (likely one nginx server for your load)

If it's actually 100 completely unrelated sites my suggestion is to have one server (but multiple processes, at least x number of cores) listening on one port. 100 node processes add too much memory overhead ( ~1-2 gb ).

OTHER TIPS

You should create multiple node servers running under multiple node processes. If you set them all up in the same node process, a crash in one http server code will bring down all other http servers as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top