Bryan Hughes - SeattleJS Conference 2017
summary
Node.js runs all JavaScript and v8 on a single thread but the event loop and native C++ work use multiple mechanisms: crypto async calls go to a default thread pool of four workers so heavy CPU work queues after four parallel tasks, file I/O and child_process also use the pool, while networking and many pipes use kernel async via epoll/kqueue/IOCP so they scale without hitting the pool. Windows has a few API differences and DNS lacks a true kernel async path.
AI-written summary · about
chapters (10)
- 0:00Start
- 0:39What is Multitasking?
- 2:36But it had limitations, so then we created Preemptive Multitasking
- 4:37But we could do better, so we created Symmetric Multi Threading (SMT)
- 10:51All JavaScript, V8, and the event loop run in one thread, called the main thread
- 12:01methods sometimes don't run in the main thread
- 12:12Example: Crypto
- 16:24Node.js uses a pre-allocated set of threads called the Thread Pool. The default is 4.
- 17:37Example: HTTP(S)
- 19:32C++ backed methods use C++ asynchronous primitives whenever possible
related talks
49mA Journey into Node.js Internals
49mA Journey into Node.js Internals
35mNodeJS: from single thread to worker threads
13mConcurrency vs Parallelism in Node.js: Understanding the Event Loop & Worker Threads
39mV8 — Inside Asynchrony and OS Interactions
41mDissecting NodeJS - How it works under the hood
39mYou Don’t Node.js
41mPut on your asynchronous hat and node
