Socket.io and redis store

1,395 views
Skip to first unread message

anlam

unread,
Apr 13, 2012, 10:50:52 PM4/13/12
to Socket.IO
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,




Dan Shaw

unread,
Apr 18, 2012, 12:34:46 PM4/18/12
to sock...@googlegroups.com
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

artem

unread,
May 14, 2012, 2:50:11 PM5/14/12
to sock...@googlegroups.com
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.

Dan Shaw

unread,
May 14, 2012, 3:31:16 PM5/14/12
to sock...@googlegroups.com
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

artem

unread,
May 14, 2012, 4:49:48 PM5/14/12
to sock...@googlegroups.com
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.
Reply all
Reply to author
Forward
0 new messages