0

If Node JS also uses a I/O thread in libuv to perform IO, how is that thread different from a thread created by IIS when it receives request for simple I/O?

Bharath
  • 25
  • 5
  • 1
    Read [this](http://stackoverflow.com/questions/10680601/nodejs-event-loop) and [this](https://www.quora.com/In-Node-js-how-does-the-event-loop-work). It could help. – Aᴍɪʀ Dec 15 '16 at 22:49

1 Answers1

2
  • Node.js does not use separate thread(s) for I/O. It multiplexes the single thread between many tasks.

  • At high level, I/O is divided into 2: n/w IO and disc IO. While the former has buffering mechanism at kernel level, node.js manages the IO in a completely asynchronous model - meaning the data is processed when the kernel buffers are absolutely ready to reciprocate the operation in a fully non-blocking mode. Disc IO still involves blocking sequences, so ndoe.js employs libuv worker threads to simulate asynchronous IO. In either ways, there is no blocking code anywhere.

  • libuv threads are pre-created and fixed in number, so there is no runtime overhead of using them.

Hope this helps.

Gireesh Punathil
  • 1,344
  • 8
  • 18