Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposed Feature: Batch join and leave #2466

Closed
nathanpeck opened this issue Mar 2, 2016 · 9 comments · Fixed by #2879
Closed

Proposed Feature: Batch join and leave #2466

nathanpeck opened this issue Mar 2, 2016 · 9 comments · Fixed by #2879

Comments

@nathanpeck
Copy link

Depending on the underlying adapter being used it may be much more efficient to join multiple rooms in one batch operation, rather than joining rooms one a time.

For example if you imagine a Slack like app where each user is in many channels, and each channel has its own socket.io room then on initial connection to the socket.io server you may need to do socket.join() for each channel the user is in. If the user is in many channels it would be much more efficient if it was possible to do a batch join operation like socket.join(['roomOne', 'roomTwo', 'roomThree']).

This would be well suited for the redis adapter for example, as the redis SUBSCRIBE operation supports multiple channels in one op.

Thoughts? Does anyone else like/need this feature?

I could easily create my own private fork with this simple feature for my own personal usage, but wanted to see if there was more general interest in adding such a feature to the mainline.

@mrbatista
Copy link

+1

@infnada
Copy link

infnada commented Mar 4, 2016

+1 my users joins a room for each "friend" to use it as a private chat. 100 friends = 100 socket.join

@baconbrad
Copy link

What is wrong with looping through a list of rooms? Unless I am missing something shouldn't the below snippet of code achieve the same thing?

var rooms = [ 'roomOne', 'roomTwo', 'roomThree' ];
for (room in rooms) {
    socket.join(rooms[room]);
}

or

var rooms = [ 'roomOne', 'roomTwo', 'roomThree' ]
for (i = 0; i < rooms.length; i++) {
    socket.join(rooms[i]);
}

@infnada
Copy link

infnada commented Mar 4, 2016

@baconface If you use redis/clusters can be a huge network traffic improvment in some cases

@nathanpeck
Copy link
Author

@baconface

This is the time breakdown for a new socket connecting to my socket.io service in which the connected user is in a number of different channels for various chat rooms they are a member of:

screen shot 2016-03-04 at 1 20 42 pm

70% of the initial connection response time is being spent sending on average 25 different SUBSCRIBE commands to the Redis machine. This would be hugely optimized if it sent just one SUBSCRIBE command with 25 channels to subscribe to, as it would reduce the network overhead of subscribing to 1/25th of what it is.

@baconbrad
Copy link

Gotcha. 👍

@NguyenTungs
Copy link

Gotcha. 👍

@NguyenTungs
Copy link

NguyenTungs commented Feb 25, 2017

@nathanpeck !
Hi There!
You said :
I could easily create my own private fork with this simple feature for my own personal usage, but wanted to see if there was more general interest in adding such a feature to the mainline.

May you help me? Please give me a idea or a suggestion. I need to solve that problem for my project.
Thanks a lot.

@dudovcic
Copy link

dudovcic commented Feb 25, 2017

That is a great idea for improvement.
+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants