You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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!');
}
The text was updated successfully, but these errors were encountered:
Try hitting it with curl http://localhost:3001/ a few times or try using different browsers and you should see it hits different processes. I believe this may be because the browser uses http keepalive, so the connection is reused.
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!
The text was updated successfully, but these errors were encountered: