Async in Node: Mental Model
On this page
Why Asynchronous Programming Exists
Node.js was designed for I/O-heavy workloads. Instead of blocking while waiting for disk or network operations, Node delegates those operations and continues executing other work.
Synchronous vs Asynchronous
const data = fs.readFileSync('file.txt');
console.log(data);
This blocks the event loop.
fs.readFile('file.txt', (err, data) => {
console.log(data);
});
This does not block the event loop.
Core Principle
Async programming allows Node to handle thousands of concurrent connections without spawning thousands of threads.
Production Insight
If your code blocks the event loop, your service becomes slow under load. Async design is not optional — it is fundamental.
Next
Let’s understand where async patterns started: callbacks.