LearnBoost / cluster

Node.JS multi-core server manager with plugins support.
http://learnboost.github.com/cluster
MIT License
2.29k stars 159 forks source link

Does cluster support socket.io node? #95

Closed lexer closed 13 years ago

lexer commented 13 years ago

Failed to find cluster google group. Does cluster support socket.io node?

3rd-Eden commented 13 years ago

No, because your polling requests could go to different servers where the sessionId might be unknown. But we are working on a Socket.IO (0.7) release that allows you scale over multiple processes.

tj commented 13 years ago

nope. like @3rd-Eden mentioned, it's more of an issue of socket.io not supporting multiple processes out of the box

xepcoh commented 13 years ago

Is it still the case with socket.io 0.8.4?

3rd-Eden commented 13 years ago

@dimux333 yes, it's still the case for 0.8.4, however!

We recently landed the RediStore backend for Socket.IO which does allow you to run cluster together with Socket.IO. I gave a small demo about this during my Nodejsconf.it session. You can find a working demo of this in my github repo (https://github.com/3rd-Eden/nodejsconfit-2011/tree/master/cluster) which will spawn a cluster of 40 processes with a working socket.io.

So support is definitely coming, but I was unable to get WebSockets working with Cluster but that could been the lack of time I had to fully investigate this behavior.

xepcoh commented 13 years ago

Thanks. I'll take a look.

DavidChouinard commented 12 years ago

@3rd-Eden & @xepcoh Sorry to revive this thread, but what's the status now? How's the support of Socket.io with Node's native cluster functionality?

tj commented 12 years ago

@DavidChouinard same thing as before, there's no such thing as "supporting node cluster", it's just the same-old multi-process issue, which you can get around by using redis etc

3rd-Eden commented 12 years ago

@DavidChouinard @visionmedia The advised way is to the RedisStore that is inside of Socket.IO (https://github.com/LearnBoost/socket.io/blob/master/lib/stores/redis.js) which will make sure that Socket.IO runs with the native cluster implementation of Nodejs and the leanboost/cluster module.

For usage see my nodejsconf-it example that I posted above.

DavidChouinard commented 12 years ago

@3rd-Eden

I copied the /socket/ directory of your repo (thanks!) and ran it. Every worker is spewing this error:

Error: Redis connection to 127.0.0.1:6379 failed - ECONNREFUSED, Connection refused
    at Socket.<anonymous> (/Users/david/Desktop/cluster/node_modules/socket.io/node_modules/redis/index.js:123:28)
    at Socket.emit (events.js:64:17)
    at Array.<anonymous> (net.js:830:27)
    at EventEmitter._tickCallback (node.js:126:26)

Clearly, the workers are failing to connect to Redis.

A bit of hacking around go me to this line:

io.set('store', new RedisStore);

My understanding is that the master is creating a Redis store and imposing Socket.io (and workers) to use it internally. Am I getting this right?

Am I supposed to somehow start Redis? Why is it failing to connect? Let me know.

Thanks!

3rd-Eden commented 12 years ago

@DavidChouinard yes it requires Redis to be installed and running.

DavidChouinard commented 12 years ago

@3rd-Eden Got it, thanks.

rcombs commented 12 years ago

I've seen people go back and forward on this; can Socket.io work with multiple processes (including Node native socket on 0.8.0) if RedisStore is used?