Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

worker pool vs libuv's threadpool in node.js

I was reading node.js docs about worker pool and faced two term which I thought both are same - worker pool and libuv's threadpool.

Here is the point of confusion (from node.js doc url):

These are the Node module APIs that make use of this Worker Pool:

I/O-intensive

DNS: dns.lookup(), dns.lookupService().

File System: All file system APIs except fs.FSWatcher() and those that are explicitly synchronous use libuv's threadpool.

Here is my understanding so far:

event loop -> can be considered main thread

worker pool -> which is implemented by libuv, so in that case worker pool thread is actually libuv thread.

So, how workers pool does something without libuv's thread?

like image 240
MD. Jahidul Islam Avatar asked Nov 15 '25 14:11

MD. Jahidul Islam


1 Answers

The "Worker Pool" and "libuv's threadpool" are the same. The reason you're misunderstanding is due to the formulation of that sentence. As a non-native English speaker myself, I can see why.

This:

File System: All file system APIs except fs.FSWatcher() and those that are explicitly synchronous use libuv's threadpool.

could instead be formulated like this:

File System: All file system APIs use libuv's threadpool, except fs.FSWatcher() and those that are explicitly synchronous.

A better formulation can be seen on the docs for UV_THREADPOOL_SIZE cli option, as seen here:

Node.js APIs that use the threadpool are:

  • ...
  • all zlib APIs, other than those that are explicitly synchronous
like image 74
Svenskunganka Avatar answered Nov 18 '25 03:11

Svenskunganka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!