DevAcademy
LearnNode.jsNode.js Architecture
BeginnerNode.js

Node.js Architecture

Understand the single-threaded event loop and libuv, the foundation of how Node.js handles concurrency.

Reading Time

12 min

Lesson

Lesson 3 of 34

Single-Threaded, Non-Blocking

Node.js runs your JavaScript code on a single main thread — but it handles many concurrent operations (file reads, network requests) without blocking that thread, by delegating slow work elsewhere and using a callback-driven event loop to pick up results when ready.

Key Architecture Pieces

PieceRole
V8Compiles and executes JavaScript
libuvA C library providing the event loop and a thread pool for I/O
Event LoopContinuously checks for completed async work and runs its callbacks
Thread PoolA small pool of background threads libuv uses for things like file system operations

Non-Blocking in Action

Try it yourself — edit and run

Console Output

Click “Run” to see the console output here.

Why This Matters

A traditional multi-threaded server might spin up a new thread per request, which is memory-heavy at scale. Node.js instead handles thousands of concurrent connections on one thread, since most server work (waiting on a database or a network call) is I/O, not CPU — exactly what the non-blocking model is optimized for.

CPU-Heavy Work Blocks Everything

The non-blocking model only helps with I/O. A genuinely CPU-intensive task (like processing a huge image synchronously) still runs on the single main thread and blocks every other request until it finishes — this is Node.js's main weakness, addressed with worker threads for CPU-bound work.

Best Practice

Node.js is an excellent fit for I/O-heavy workloads (APIs, real-time apps) and a poor fit for CPU-heavy workloads (video encoding, heavy computation) on the main thread — know which kind of work your application actually does.

Interview Questions

Quick Quiz

1. How many main threads does a Node.js process run JavaScript on?

2. What is libuv responsible for?

3. Why can a CPU-heavy synchronous task be a problem in Node.js?