Concurrency Model: Non-blocking I/O Explained
On this page
Concurrency vs Parallelism
Node.js achieves concurrency through asynchronous I/O. It does not create one thread per request.
Non-Blocking I/O
When waiting for disk or network, Node delegates work and continues processing other events.
Worker Threads
For CPU-bound tasks, Node provides worker threads to achieve parallel execution.
Example Concept
import { Worker } from 'worker_threads';
Production Strategy
- Use async I/O for scalability.
- Offload CPU tasks.
- Monitor event loop lag.