Hi all

I have a node app as followed. I wanted to test node js's ability to handle 
huge amount of requests.

var cluster = require('cluster');

if (cluster.isMaster) {
    require('os').cpus().forEach(cluster.fork);

    cluster.on('exit', function(worker, code, signal) {
        console.log('worker ' + worker.process.pid + ' died');
        cluster.fork();
    });
}
else {
    // cluster's worker process
    setupServer();
}

var output = 'long long long string'

function setupServer() {
    var http = require('http');
    var server = http.createServer(function (req, res) {
if (req.url == '/respond') {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end(output);
} else {
res.writeHead(404, {"Content-Type": "text/plain"});
res.write("404 Not found");
res.end();
}
    });
    server.listen(80);    
}

So I run this server and start hitting it. I have a 4 core machine and it 
seems that only 1 core was being hit. There were 5 processes overall but 
only 1 process were consuming CPU. Did I do something wrong? Do I have to 
do some setup or change my code in order to utilize all my cores?

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to