I am trying to understand how non-blocking network IO is working in Node.js
/libuv
. I already found out that file IO is done using libuv
worker threads (thus, in a background thread). However it is stated in various places that network IO is done in a non-blocking fashion using system calls like epoll
, kqueue
, etc (depending on operating system).
Now I am wondering if this means that the actual IO part (read()
) is still done on the mainthread, and thus blocking, even if e. g. epoll
is used? As for my understanding, epoll
only notifies about available events, but does not actually do the read/write. At least in the examples I found (e. g. http://davmac.org/davpage/linux/async-io.html) epoll
is always used in combination with the read
system call, which is a blocking IO operation.
In other words, if libuv
is using a single thread and epoll
, to have a notification when data is available to read, is the then following read operation beeing executed on the mainthread and thus potentially blocking other operations (thinking of network requests) on the mainthread?