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: #20876
  • Loading branch information
tniessen committed Jan 20, 2022
1 parent 110aa38 commit 296d627
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions doc/api/cluster.md
Original file line number Diff line number Diff line change
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 @@ -1109,6 +1111,7 @@ socket.on('data', (id) => {

[Advanced serialization for `child_process`]: child_process.md#advanced-serialization
[Child Process module]: child_process.md#child_processforkmodulepath-args-options
[worker threads]: worker_threads.md
[`.fork()`]: #clusterforkenv
[`.setupPrimary()`]: #clustersetupprimarysettings
[`ChildProcess.send()`]: child_process.md#subprocesssendmessage-sendhandle-options-callback
Expand Down

0 comments on commit 296d627

Please sign in to comment.