Note that there are some explanatory texts on larger screens.

plurals
  1. POConfusion about node.js internal asynchronous I/O mechanism
    primarykey
    data
    text
    <ol> <li>I have learned that node.js use libeio internally to perform async <strong>file</strong> I/O, with thread pool, on *nix platform, am I right? </li> <li>What about async <strong>network</strong> I/O? Is it done by libev? Is there also a thread pool? </li> <li>If there is thread pool inside, how could it be more efficient than traditional one-thread-per-request model? And is it one thread per I/O request?</li> <li>And what's the mechanism on windows? I know it's done by IOCP, and there's a kernel level thread pool, right?</li> <li>Why linux doesn't have a native completely AIO mechanism like windows IOCP yet? Will it have in future?</li> </ol> <p>Update according to changchang's answer: </p> <ol> <li>I took a quick view at the <a href="https://github.com/joyent/libuv/blob/master/src/unix/threadpool.c" rel="noreferrer">source code</a> @changchang have given, found that the default thread pool size can be reset by <strong>UV_THREADPOOL_SIZE</strong>, I'm wondering in which case this will be used? </li> <li>I also found getaddrinfo use this thread pool, is there any more except fs? And if all sync jobs will be done in this thread pool, is the default size '4' enough? </li> <li>As my understanding now, there will be 6 basic threads in node.js process: 1 V8 thread(event loop, where user javascript codes runs), 1 libuv event loop, and 4 in thread pool, am I right? </li> <li><p>And how can I see these threads in my shell(Ubuntu)? I use <strong>ps -eLf | grep node | grep -v grep</strong> only saw two:</p> <p>root 16148 7492 16148 0 2 20:43 pts/26 00:00:00 ./bin/node /home/aaron/workspace/test.js<br> root 16148 7492 16149 0 2 20:43 pts/26 00:00:00 ./bin/node /home/aaron/workspace/test.js</p></li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload