Why Node.js?

Knowledge Videos

Short animated explainers, organised by subject.

Why Node.js?

Why a single thread with an event loop suits I/O-heavy servers, and where it breaks down.

Transcript

Node.js runs JavaScript outside the browser, on Chrome's V8 engine.

Most servers spend their time waiting on databases, files and networks.

Instead of one thread per request, Node uses one thread and an event loop.

A slow operation is handed off. When it finishes, its callback is queued and run.

Thousands of connections stay cheap, but one heavy calculation blocks everyone.

So Node shines at I O heavy work, and uses worker threads for heavy CPU jobs.

Never block the loop.

More in this series