1

After reading this post, it has given me the impression that Node starts its event loop only when I start a server, with the listen() method.

Is that true ?

What happens if I start multiple servers on different ports ? Does that mean there are multiple event loops per server ?

Also what happens if on one terminal I write-:

node server1.js

and on the second terminal I write

node server2.js

How may node processes will be there and how many event loops will be running ?

So does the event loop start up with the node.js runtime or is it specific to the starting of an app/server ?

ng.newbie
  • 2,807
  • 3
  • 23
  • 57
  • 1
    Definitely take a look here http://stackoverflow.com/questions/25568613/node-js-event-loop and http://stackoverflow.com/questions/22644328/when-is-the-thread-pool-used – Wiktor Zychla Dec 14 '16 at 12:07
  • @WiktorZychla I am sorry but I couldn't find the answer I was looking for. My question is that whether there is a single event loop for the entire Node runtime ? or is a loop started everytime I start a server. I guess that was not clear in my question so I have edited it. – ng.newbie Dec 15 '16 at 04:56
  • Yes, there is a single loop per process. No, it starts regardless of your server, your app can do anything simpler than a server and you still have the loop there. – Wiktor Zychla Dec 15 '16 at 06:41
  • @WiktorZychla So, just correct me if I am wrong. If I write in one terminal `node server1.js` and open and another terminal and write `node server2.js` it will start another node process right ? – ng.newbie Dec 15 '16 at 07:18
  • Yes, `node` is an OS app that, when invoked, starts a new process. – Wiktor Zychla Dec 15 '16 at 08:29

0 Answers0