From de7fb3387980666f40ea5224992bc4068c430a6d Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 12 Oct 2011 14:19:32 -0700 Subject: [PATCH] Add some docs for node cluster --- doc/api/_toc.markdown | 1 + doc/api/cluster.markdown | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 doc/api/cluster.markdown diff --git a/doc/api/_toc.markdown b/doc/api/_toc.markdown index b5e8d6df87c..e2563419e8b 100644 --- a/doc/api/_toc.markdown +++ b/doc/api/_toc.markdown @@ -32,6 +32,7 @@ * [ZLIB](zlib.html) * [OS](os.html) * [Debugger](debugger.html) +* [Cluster](cluster.html) * Appendixes * [Appendix 1: Recommended Third-party Modules](appendix_1.html) * [Appendix 2: Deprecated API's](appendix_2.html) diff --git a/doc/api/cluster.markdown b/doc/api/cluster.markdown new file mode 100644 index 00000000000..6e02f484860 --- /dev/null +++ b/doc/api/cluster.markdown @@ -0,0 +1,23 @@ +## Cluster + +A single instance of Node runs in a single thread. To take advantage of +multi-core systems the user will sometimes want to launch a cluster of Node +processes to handle the load. + +By starting node with the `cluster` argument, Node will detect the number of +CPUs on the machine and start that many processes. For example suppose we +had a simple HTTP server in server.js: + + require('http').createServer(function(req, res) { + res.writeHead(200); + res.end('hello world\n'); + }).listen(8000); + +If we start it like this + + % node cluster server.js + Detected 2 cpus + Worker 2438 online + Worker 2437 online + +Node will automatically share port 8000 between the multiple instances.