100% CPU
Hi, when I start this for some reason. I am seeing CPU spike to 100% when using with the cluster module:
MongoStore = require('socket.io-mongo')
cluster = require('cluster')
numCPUs = require('os').cpus().length;
// This is what the workers will do.
workers = function() {
io = require('socket.io').listen(8080);
io.configure(function() {
io.set('store', new MongoStore())
})
}
// Start forking if you are the master
if (cluster.isMaster) {
for (var i = 0; i < numCPUs; i++) { cluster.fork() }
} else { workers() }
node: 0.8.14 socket.io-mongo: 0.0.8 socket.io: 0.9.13
I need to update to the latest mubsub version, it should be fixed there.
@kof is there maybe an older npm version for "socket.io-mongo" where the code is working?
I think this bug was the whole time there, but it was not always reproducible.
If you wait some days I will migrate to the new version of mubsub. Do you want to use it in production?
Yea, I wanted to use it in production.
@kof awesome - also wonder if you're looking into the issue with {safe: true} that keeps popping up? I couldn't see a way to pass in that option
I think you can pass proper options already.
I'm seeing this same issue -- 100% CPU usage with cluster. I'm using node.js 0.8.12 and the latest versions of all modules.
heh ... need to find time to finally complete this one #3
Ack, I wish I had read through the issues before moving this from my staging server (which doesn't use cluster) to production (which does). #kaboom there goes my whole server array :(
actually this issue should exist also without cluster
Is there any way I can easily work around this? I'm in a tight spot -- I just pushed a whole bunch of code to production, and my servers are now down. I hate to do a rollback, but it may be the only option...
try to merge this pull .... #3 also good to know if it works ... haven't checked yet ... tests are not running but probably it works for you ...
Please excuse my ignorance -- is there a way to install the pull with NPM?
yes, you can fork it and reference it directly to your fork in your package.json
example:
"connect-mongodb" : "https://github.com/my-account/connect-mongodb/tarball/master",
Well... as best as I can tell, the CPU is fixed, but the module no longer works. I'm getting "client not handshaken" errors from socket.io (eg, the connections are not shared).
There are a bunch of console.log statements being spit out, too, like the following:
{ name: 'open', nodeId: 424686859572, args: '["GopX4DCM9mgy3h93h25-"]', _id: 5146480b16dcde722f000025 } { name: 'open', nodeId: 424686859572, args: '["GopX4DCM9mgy3h93h25-"]', _id: 5146480b16dcde722f000028 }
Ok, then I need to make all tests running again and find out whats not ported or wrongly ported in this pull ... so sorry, no quick solution right now.
Ok, thanks -- let me know if I can help at all. I've fallen back on long-polling on my prod servers for now, but it's a bit of a patch solution which I'd like to correct. So, any testing you need, just LMK ;)
Hey kof... any chance you have some time to take a look at this? It would be much appreciated.
I will try to find it ...