Skip to content

Cluster Worker load balancing imbalance #188

@ynkm169

Description

@ynkm169

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions