image.png

Is Node.js Single-Threaded?

โžก๏ธ Yes AND No.


libuv Thread Pool โ€” What & Why?

Libuv is C-based library in Node.js that manages:

# You can customize thread pool size
process.env.UV_THREADPOOL_SIZE = 8;

Diagram Breakdown (from your image):

  1. V8 JS Engine
  2. libuv handles:
  3. Thread Pool

๐Ÿงช Real Example: crypto.pbkdf2 using Thread Pool


const crypto = require("crypto");

console.time("hash");

for (let i = 0; i < 5; i++) {
  crypto.pbkdf2("password", "salt", 100000, 64, "sha512", () => {
    console.timeEnd("hash");
  });
}