0

Does node.js is create an instance of a node.js for each client, or there is only one instance of node.js server for a whole variety of clients and unique instances created only for paths for each client ?

Grenudi Idunerg
  • 69
  • 1
  • 11

1 Answers1

2

Nodejs doesn't create a new server instance for each client, neither do other options out there.

You're probably thinking of multithreading as traditionally multithreaded web servers create a new thread for each client request, however since node.js runs JavaScript which is single threaded the answer is no - every client request is handled by the same single thread.

That is why Node.js and JavaScript are often associated with the word blocking referring to the fact that if you write code that takes a long time to complete, it will block all the other users from getting served. You don't however have to worry about blocking when performing I/O since Node.js (JavaScript) is asynchronous - meaning that client requests won't block each other when performing I/O operations such as network requests or disk reads.

To read more on Node.js being single threaded, see this S/O answer: Why is Node.js single threaded?

linasmnew
  • 3,907
  • 2
  • 20
  • 33