Skip to content

Commit 312b0fc

Browse files
authored
doc: suggest worker threads in cluster docs
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 <benjamingr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Mestery <mestery@protonmail.com>
1 parent d01c645 commit 312b0fc

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

doc/api/cluster.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
77
<!-- source_link=lib/cluster.js -->
88

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

1314
The cluster module allows easy creation of child processes that all share
1415
server ports.
@@ -1121,3 +1122,4 @@ socket.on('data', (id) => {
11211122
[`process` event: `'message'`]: process.md#event-message
11221123
[`server.close()`]: net.md#event-close
11231124
[`worker.exitedAfterDisconnect`]: #workerexitedafterdisconnect
1125+
[`worker_threads`]: worker_threads.md

0 commit comments

Comments
 (0)