Update according to changchang's answer:
And how can I see these threads in my shell(Ubuntu)? I use ps -eLf | grep node | grep -v grep only saw two:
root 16148 7492 16148 0 2 20:43 pts/26 00:00:00 ./bin/node /home/aaron/workspace/test.js
root 16148 7492 16149 0 2 20:43 pts/26 00:00:00 ./bin/node /home/aaron/workspace/test.js
NodeJS is an asynchronous event-driven JavaScript runtime environment designed to build scalable network applications. Asynchronous here refers to all those functions in JavaScript that are processed in the background without blocking any other request.
Asynchronous programming in Node. js. Asynchronous I/O is a form of input/output processing that permits other processing to continue before the transmission has finished.
js. JavaScript is asynchronous in nature and so is Node. Asynchronous programming is a design pattern which ensures the non-blocking code execution.
Node. js uses callbacks, being an asynchronous platform, it does not wait around like database query, file I/O to complete. The callback function is called at the completion of a given task; this prevents any blocking, and allows other code to be run in the meantime.
First of all, libuv
has removed the libeio
from it. But it does perform async file I/O with a thread pool like libeio
just as you mentioned.
libuv
also removes libev
. It does the async network I/O based on the async I/O interfaces in different platforms, such as epoll
, kqueue
and IOCP
, without a thread pool. There is a event loop which runs on the main thread of uv
which polls the I/O events and processes them.
The thread pool inside libuv
is a fixed size thread pool (4 in uinx like system). It performs a task queue role and avoids the exhaustion of the system resources by generating threads indefinitely when the requests increase.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With