Skip to content

Issue in cluster module while running an http server #8540

@GavinDmello

Description

@GavinDmello
  • Version: 4.4.7
  • Platform: Darwin Kernel Version 15.5.0 root:xnu-3248.50.21~8/RELEASE_X86_64 x86_64
  • Subsystem: Cluster module

I'm not sure if a bug or not. I'm running an http server within the cluster module and all my requests seem to go the same process. I'm logging the pid and every time I get a request I get the same pid. I'm also setting the policy as cluster.SCHED_RR for a round robin. Some help would be great!

var cluster = require('cluster');
cluster.schedulingPolicy = cluster.SCHED_RR
if (cluster.isMaster) {
    var cpuCount = require('os').cpus().length;
    for (var i = 0; i < cpuCount; i += 1) {
        cluster.fork();
    }
} else {
    console.log('Four child processes created', process.pid)
    var express = require('express');
    var app = express();

    app.get('/', function(req, res) {
        console.log(process.pid)
        res.send('Hello World!');
    });
    app.listen(3001);
    console.log('Application running!');

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    clusterIssues and PRs related to the cluster subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions