Skip to the page

How Node runs your code · core

What Node.js is: V8 + libuv

Node.js is a JavaScript runtime: the V8 engine runs your JavaScript on one main thread, and the libuv library gives it an event loop and non-blocking I/O, so one process can serve many connections at the same time.

The notes

What you must know

  • V8 compiles and runs JavaScript and does garbage collection. libuv gives the event loop, a small thread pool and cross-platform async I/O. C++ bindings connect them to core modules like fs, net, http and crypto.
  • Your JavaScript runs on one thread. Waiting for I/O (network, disk) does not block it: Node starts the operation, keeps running other code, and runs your callback when the result is ready.
  • Network I/O uses the operating system's async mechanisms (epoll on Linux, kqueue on macOS, IOCP on Windows). File system calls, dns.lookup, some crypto and zlib run on the libuv thread pool.
  • Good fit: I/O-heavy servers (APIs, BFFs, real-time, proxies). Poor fit without extra work: CPU-heavy work (image processing, huge JSON, hashing in a loop), because it blocks the one JS thread for every user.
  • Different from the browser: no DOM or window; it has process, Buffer, require/module, fs, net. Many web APIs now exist in Node too: fetch, URL, AbortController, Web Streams, a WebSocket client.
  • 'Single-threaded' is about your JavaScript. The Node process itself has several threads (the thread pool, V8 garbage collection and compiler threads).

The red pen

Common traps: mistake → fix

  • Mistake: Node is single-threaded, so it does one thing at a time

    Fix: only your JavaScript runs on one thread; I/O waits happen in the OS or the thread pool, so thousands of requests can be in flight.

  • Mistake: libuv makes Node multi-threaded for my code

    Fix: the thread pool is small (4 by default) and used by specific APIs; all request handlers still share one JS thread.

  • Mistake: Node is good for every backend job

    Fix: CPU-bound work blocks every request; move it to worker threads or another service.

Easy to hard

Questions interviewers ask, easy to hard

  1. What is Node.js? Is it a language, a framework or a runtime?
  2. How can a single-threaded runtime handle 10,000 open connections?
  3. What do V8 and libuv each do?
  4. Which work runs on other threads, and which on the main thread?
  5. When would you not choose Node for a backend service?

Practise

Practise with these questions

Explain it out loud

Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.

Practise by voice

Your first interview is free

Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.

Start your free interview