The Node.js Event Loop: Not So Single Threaded
summary
Node.js runs JavaScript on a single main thread but offloads work in three ways: CPU-heavy calls like pbkdf2 go to a reusable thread pool = 4 so parallel hashes queue when all workers are busy; network and some OS IO use kernel async and never tie up the pool; many file system and DNS lookups fall back to the thread pool. Expect blocking when CPU-bound work exceeds available cores or pool threads.
AI-written summary · about
chapters (11)
- 0:00Introduction to multitasking
- 1:25Cooperative multitasking
- 5:05Pre-emptive multitasking
- 7:21Symmetric multi-threading
- 9:43Processes vs threads
- 15:23Node.js threading model
- 17:35Crypto and the thread pool
- 23:53Networking and event loops
- 28:44Inside the event loop
- 34:40Future of node threading
- 36:52Q&A session
