Skip to content

Commit

Permalink
doc: suggest worker threads in cluster docs
Browse files Browse the repository at this point in the history
The current documentation is incorrect in that it says "A single
instance of Node.js runs in a single thread," which is not true due
to the addition of worker threads.

This patch removes the incorrect statement and instead suggests that
applications consider using worker threads when process isolation is
not needed.

Refs: nodejs#20876
  • Loading branch information
tniessen committed Jan 20, 2022
1 parent 110aa38 commit 6eb266a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions doc/api/cluster.md
Expand Up @@ -6,9 +6,11 @@
<!-- source_link=lib/cluster.js -->

A single instance of Node.js runs in a single thread. To take advantage of
multi-core systems, the user will sometimes want to launch a cluster of Node.js
processes to handle the load.
Clusters of Node.js processes can be used to run multiple instances of Node.js
that can distribute workloads among their application threads. When process
isolation is not needed, the newer [worker threads][] module can be used
instead, which allows running multiple application threads within a single
Node.js instance.

The cluster module allows easy creation of child processes that all share
server ports.
Expand Down Expand Up @@ -1122,3 +1124,4 @@ socket.on('data', (id) => {
[`process` event: `'message'`]: process.md#event-message
[`server.close()`]: net.md#event-close
[`worker.exitedAfterDisconnect`]: #workerexitedafterdisconnect
[worker threads]: worker_threads.md

0 comments on commit 6eb266a

Please sign in to comment.