JavaScript Internals (521 Qs)•Part 7: Execution Context, Functional JS & V8 Engine (404 - 463)
Is Node.js completely single threaded
Node is a single thread, but some of the functions included in the Node.js standard library(e.g, fs module functions) are not single threaded. i.e, Their logic runs outside of the Node.js single thread to improve the speed and performance of a program.
Practical Code Example
javascript
// Is Node.js completely single threaded?
// NO. The JavaScript execution thread is single-threaded,
// but the underlying libuv runtime uses a multi-threaded Thread Pool (default 4 threads)
// for expensive operations: fs, crypto, zlib, and dns.lookup.