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

PR-URL: #41616
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Mestery <[email protected]>
  • Loading branch information
tniessen authored Jan 23, 2022
1 parent d01c645 commit 312b0fc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions doc/api/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
<!-- 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, use the [`worker_threads`][] module 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 @@ -1121,3 +1122,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 312b0fc

Please sign in to comment.