Node.js Isn't Single-Threaded. How libuv and the OS Kernel Actually Run Your Code.
A visual, 10-minute architectural deep dive into Node.js runtime internals. Learn how V8, the libuv threadpool, OS kernel event demultiplexers (epoll/kqueue/IOCP), the 6-phase event loop, and Worker Threads execute JavaScript under the hood.
First seen by Oriel on .
AI summary
The article explains that Node.js exposes single-threaded JavaScript execution while libuv worker threads and OS kernel event mechanisms handle blocking work and network concurrency.
- V8 runs JavaScript on one main thread, so synchronous loops and expensive calculations can monopolize the CPU and block the application.
- Network I/O bypasses libuv’s worker pool, using epoll, kqueue, or IOCP to monitor many non-blocking sockets concurrently.
- File operations, crypto, zlib, and dns.lookup share a four-thread libuv pool, which can cause queued work and cross-service latency spikes.
- The event loop has six phases, while process.nextTick and Promise callbacks use separate microtask queues that run whenever the JavaScript stack empties.
- Recursive process.nextTick calls can starve every event-loop phase, preventing HTTP requests, database responses, and completed file operations from being processed.
#node.js #libuv #event loop #concurrency
Generated by gpt-5.6-sol. Check the original for details.
Metric trends
Last 30 days · Up to 120 recorded samples per source and metric, with reposts kept separate · First and latest retained
Reactions
Total public reactions reported by the source; distinct from points and likes.
- DEV Community: 24, latest observation ; +12 over observed period since
Comments
Comment count reported by the source.
- DEV Community: 4, latest observation ; +3 over observed period since
Aliases
| Source | External ID | URL |
|---|---|---|
| DEV Community | 4826006 | https://dev.to/smtahosin/nodejs-isnt-single-threaded-how-libuv-and-the-os-kernel-actually-run-your-code-3460 Read discussion |