0

I understand that NodeJS uses a thread pool for blocking I/O calls. What does it do if all the threads in the thread pool are busy with some work and another request comes in?

ekhan
  • 231
  • 1
  • 4
  • 11
  • Duplicate of [When is the thread pool used?](http://stackoverflow.com/questions/22644328/when-is-the-thread-pool-used). Great answers in that post and a reference link to an article that also explains a lot. If the thread pool is all busy and a new async tasks that needs a thread is requested, it goes in a queue and it doesn't get started until a thread is available. – jfriend00 May 22 '15 at 06:04

1 Answers1

0

In a case where the thread pool is needed and no workers are available, the request would be queued until a worker is free. The thread pool is not the sole approach, though. There are three operation types that utilize the thread pool in libuv as documented at the bottom of the page here under the title File I/O.

These operations types are:

  • Filesystem operations
  • DNS functions (getaddinfo and getnameinfo)
  • User-specified code

While not a direct answer to your question, I believe this post by Jason does a wonderful job of explaining thread pools in Node.js. Without going extremely in-depth, it introduces you to the functionality provided the libuv library and has links to very informative literature on the subject of the thread pool.

Community
  • 1
  • 1
Zachari
  • 1
  • 1