Confusion About Node.js Internal Asynchronous I/O Mechanism
Solution 1:
- First of all, - libuvhas removed the- libeiofrom it. But it does perform async file I/O with a thread pool like- libeiojust as you mentioned.
- libuvalso removes- libev. It does the async network I/O based on the async I/O interfaces in different platforms, such as- epoll,- kqueueand- IOCP, without a thread pool. There is a event loop which runs on the main thread of- uvwhich polls the I/O events and processes them.
- The thread pool inside - libuvis 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.
Solution 2:
Uptil version 0.6 node used libev to run event-loop and libeio for asynchronous I/O, (Unix backend sits heavily on these two libraries). But libuv has started replacing libev and libeio in version 0.8. It performs, mantains and manages all the io and events in the event pool. libuv is the choice in cross-platform asynchronous IO libraries.
- Yes, upto node 0.6, deprecated in 0.8 and uses thread pool
- Yes, but - libevdoes not use thread pool. See here- Clarification : According to the link in the question I posted, - libeiodoes support all POSIX functions dealing with I/O (which includes socket). But node author decided to use it for async file I/O only, and uses- libevfor network I/O. I dont know where you heard it from but you can use epoll on regular files.
- libevuses event loop so no problems here.
- Yes IOCP handles async I/O in windows, kernel does use thread pools.
- New linux kernel has epoll, kqueue in new BSD kernel. libevandlibeiowere for linux environment and provides event loop/async IO for all kernel (supports select, poll, epoll, kqueue).
Update questions:
- dont know much about libuv
- maybe enough (dont know)
- Here are my findings on Windows 8, checked it via Process Explorer. Showed 4 threads, 1 DLL, 1 File and 1 Section (total 7 entries) for a node application process. 
- ps -eLfdoes show all threads and processes, maybe you are over-filtering it, just look for the node process pid like- ps -eLf | grep xwhere x is pid for node process.
Post a Comment for "Confusion About Node.js Internal Asynchronous I/O Mechanism"