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 ?

5
  • 1
    Definitely take a look here stackoverflow.com/questions/25568613/node-js-event-loop and stackoverflow.com/questions/22644328/… Commented Dec 14, 2016 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. Commented Dec 15, 2016 at 4: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. Commented Dec 15, 2016 at 6: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 ? Commented Dec 15, 2016 at 7:18
  • Yes, node is an OS app that, when invoked, starts a new process. Commented Dec 15, 2016 at 8:29

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.