javascript - Running multiple httpServer in one Node Process or each server in own node process -
i'm trying figure out what's better solution.
i running 2 http servers in node app, server 1 @ port 3000, server 2 on port 3001. server 1 making main logic , database handling, while server 2 handles file requests.
when start app node myapp.js both servers launched , listening ports.
/* *fire servers */ http.createserver(app).listen(3000, function(){ console.log('http express server listening on port 3000'); }); http.createserver(fileserver).listen(3001, function(){ console.log('http fileserver listening on port 3001'); });
now question: know if make difference if write every server own node process, have run node myapp.js launches server 1, listening on port 3000 , run node myfileserver.js listens on port 3001.
is there performance difference? or hints can read it?
regards, martin
depends on rest of code. if both servers have shared states it's better start them in same process.
if there no shared state it's better have them in separate processes one's execution flow not affect number of requests server other one. specially true if 1 io bound , other 1 cpu intensive.
also if starting them in same process why not both things on same port?
Comments
Post a Comment