Socket.io and redis store

Showing 1-7 of 7 messages
Socket.io and redis store anlam 4/13/12 7:50 PM
Hi,

There are a couple of things that I couldn't understand. If you can
clarify these, I'll really appreciate it.

We can use redis in two ways.

- First, we can use it as a storage so whenever we spawn a new
process, we can attach the new socket.io process to it and socket
states can be shared.

- Second, we can also use it for pub sub. So redis can also handle pub
sub.

Have I understood correctly? If so, does redis emit messages to the
clients? Does it mean that the heavy job will be on redis if we use
pub sub as well? (which means we'll be mainly scaling redis if we are
sending lots of messages). So, if I am broadcasting a message to 100
people, will socket.io send the message to redis and than redis will
send to 100 people? If all these correct, does it mean I should expect
a better performance when using pub sub as well? If not, why should I
use pub sub? What is the use case?

I may have understood completely wrong too, I am a bit confused.

Thanks in advance,




Re: Socket.io and redis store dshaw 4/18/12 9:34 AM
RedisStore provides light-weight persistance and uses Redis pub/sub
*internally* to keep Socket.io processes in sync. You still interface
with Socket.io's built in pub/sub mechanisms like namespaces and
rooms.

Daniel Shaw
@dshaw

Re: Socket.io and redis store artem 5/14/12 11:50 AM
Hi Daniel,

Will this work with xhr-polling transport?  I am using RedisStore to store connection information between two node processes, it is working and connections persist between the processes.  Using this example https://gist.github.com/1391583.  However,  I cant broadcast data between the two node processes.  Do I have to manually write up pub/sub if using xhr-polling?  We are on heroku, scaling to multiple dynos.

Thanks.
Re: Socket.io and redis store dshaw 5/14/12 12:31 PM
Artem,

Hopefully, 0.9.7 will come out soon, but for RedisStore and XHR you
need to use Socket.io HEAD to pick up #848
(https://github.com/LearnBoost/socket.io/pull/848) from Mike Brevoort.

You can do this in your package.json:

{
  "dependencies": {
    "socket.io" : "https://github.com/LearnBoost/socket.io/tarball/master"
  ...

I recommend bumping back to the release version as soon as it comes
out though. This is a server-side only patch, so you don't need to
worry about socket.io-client.

Daniel Shaw
@dshaw
Re: Socket.io and redis store artem 5/14/12 1:49 PM
Hi Dan,

Thanks for the quick reply.  I applied the #848 patch but it did not fix the issue.  Just to be clear, my issue is that clients on multiple node processes do not receive broadcasts if I am using xhr-polling.  For example,  I have 2 node processes, A and B.  If I have clients on A and B,  they cant broadcast to each other.  The same thing happens if a client originally connected to A and got switched to B.  So the clients receive messages only if they are on the same node process.  Is this normal behavior with xhr-polling transport, or should all node processes be receiving broadcasts?

Thanks.
Re: Socket.io and redis store Oleg Slobodskoi 7/2/12 5:43 AM
Exactly the same issue here, also the patch did not help. Using heroku and xhr-polling.
Re: Socket.io and redis store Oleg Slobodskoi 7/2/12 7:37 AM
I have just modified the oriignal chat from examples using redis and http-proxy with 3 servers, which are load balanced without to forward same user to same server.

This is clearly demonstrates the issue.