Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cluster Worker load balancing imbalance #188

Open
ynkm169 opened this issue Sep 9, 2014 · 0 comments
Open

Cluster Worker load balancing imbalance #188

ynkm169 opened this issue Sep 9, 2014 · 0 comments

Comments

@ynkm169
Copy link

ynkm169 commented Sep 9, 2014

I am just writing this separate issue here:

I used an simple test websocket example like the official doc. Nothing fancy.
One worker is working CPU to 100%. The other workers working like 5%..
Seems like the load balancing algorithm does not do round robin correctly....
When 1 CPU is loaded to 100% it causes problems maybe using a lot of memory which might break v8 1.7GB memory limit.

BTW, I am launching 100k connections with only two client simulation machine though (each machine launching about 50k test client connections) This means all 100k clients only have 2 unique IP. I am not sure how cluster module balances connections in relation to IP though.
According to the official doc and example:
http://nodejs.org/api/cluster.html

var cluster = require('cluster');
var http = require('http');
var numCPUs = require('os').cpus().length;

if (cluster.isMaster) {
    // Fork workers.
    for (var i = 0; i < numCPUs; i++) {
        cluster.fork();
    }

    cluster.on('exit', function(worker, code, signal) {
        console.log('worker ' + worker.process.pid + ' died');
    });
} else {
    // Workers can share any TCP connection
    // In this case its a HTTP server
    http.createServer(function(req, res) {
        res.writeHead(200);
        res.end("hello world\n");
    }).listen(8000);
}

When I actually remove all cluster code and instead launch say 6 node instances on 6 different ports and use HAproxy to do load balancing. All my workers are extreamly balanced, which is what I wanted...But I really don't want to use HAproxy if I could just use cluster module.

@ynkm169 ynkm169 changed the title Cluster CPU load balancing imbalance Cluster Procoess load balancing imbalance Sep 9, 2014
@ynkm169 ynkm169 changed the title Cluster Procoess load balancing imbalance Cluster Worker load balancing imbalance Sep 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant