3 ms·
The Node server is single-threaded and multiplexes requests when they yield control (for instance, when they make an async database call). Depending on how real
by al2o3cr 10y ago
The Node server is single-threaded and multiplexes requests when they yield control (for instance, when they make an async database call). Depending on how realistic your "dummy operations" are, that may not be happening at all.
If you want parallelism, you'll need to add it yourself:
http://mobilenext.net/scaling-node-js-multi-core-systems/ http://mobilenext.net/scaling-node-js-multi-core-systems/
- netgusto 10y ago> If you want parallelism, you'll need to add it yourself I guess that's the way to go. The article you mentioned has an interesting demo : https://github.com/chaudhryjunaid/multicore-demo/blob/master/bin/multicore.js https://github.com/chaudhryjunaid/multicore-demo/blob/master... Though I'll yet have to figure out how to share the server state between the server workers then. Thanks for your answer.
- netgusto 10y agoMaybe more appropriate even than the node "cluster" in this demo is https://github.com/xk/node-threads-a-gogo https://github.com/xk/node-threads-a-gogo > Why threads ? > 4.- The threads of a process share exactly the same address space, that of the process they belong to. Every thread can access every memory address within the process' address space. This is a very appropriate setup when the threads are actually part of the same job and are actively and closely cooperating with each other. Passing a reference to a chunk of data via a pointer is many orders of magnitude faster than transferring a copy of the data via IPC.