I am not a node.js master, so I would like to have more points of view about this.
I am creating an HTTP node.js web server that should handle not only many simultaneous connections, but also lengthy work tasks. By default, node.js runs in one process, and if the part of the code that takes a long time to complete any subsequent connection must wait until the code finishes what it does in the previous connection.
For instance:
var http = require('http');
http.createServer(function (req, res) {
doSomething();
}).listen(1337, "127.0.0.1");
So, I was thinking of starting all lengthy work tasks in separate threads using the node-webworker library :
var http = require('http');
var sys = require('sys');
var Worker = require('webworker');
http.createServer(function (req, res) {
var w = new Worker('doSomething.js');
}).listen(1337, "127.0.0.1");
, cluster node .
, cluster (, 4 node , ), node-webworker.
- ?