From bbe95cfa00e69e2584efcd5120586f71e7105f38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Nie=C3=9Fen?= Date: Thu, 20 Jan 2022 18:43:29 +0100 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/20876 --- doc/api/cluster.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/api/cluster.md b/doc/api/cluster.md index 609a334d97917c..49000b5bba0c2b 100644 --- a/doc/api/cluster.md +++ b/doc/api/cluster.md @@ -6,9 +6,10 @@ -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. @@ -1122,3 +1123,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