On Thu, Nov 8, 2012 at 12:04 AM, Isaac Schlueter <
i...@izs.me> wrote:
> Node uses threads for file system IO and for some slow CPU-intensive
> operations, and for system calls that are not available
> asynchronously, and for spawning child processes (since you can't
> actually do that without a fork call.)
>
> It does *not* use threads for async network IO, because it's
> unnecessary, and it certainly does not spawn a thread for each request
> to an HTTP server, or for each outbound HTTP request it makes.
Sorry Isaac, I'm afraid I have to amend that a little. :-)
* Child processes are spawned synchronously. (But afterwards, process
management is event-driven.) That may change if it becomes an issue
but that hasn't been the case so far.
* While HTTP traffic is event-driven, the initial DNS lookup is done
from inside the thread pool. That's because we use getaddrinfo(3)
instead of c-ares, mostly because the latter doesn't support things
like mDNS (think Bonjour, Avahi, etc.). I may switch it to
getaddrinfo_a(3) on Linux someday but other platforms will keep on
using the thread pool.