26.2 CPU
Node.js needs the processor as a resource so that computations can be performed. This can be simple things like calculating 1 + 1, but also complex operations like parsing an extensive JavaScript Object Notation (JSON) structure. Modern systems usually have at least several processor cores to which the work can be distributed. The architecture of Node.js follows a single-process and a single-threaded approach. Everything you run in Node.js runs in one process and potentially blocks each other. You can solve this problem using the child_process and worker_threads modules. Chapter 16 describes how this exactly works.
The asynchronous input and output approach allows Node.js to swap out to the operating system all operations that aren’t ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access