Chat example using Cluster + Redis Adapter #1815
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I have forked the chat example and made it work using Cluster. There is an updated README within the example's directory that instructs you on how to configure Redis.
My solution used the
sticky-session
module (https://github.com/indutny/sticky-session) for routing requests to a slave based on IP address. This means that if you want to test this application, you will need to hit index.html from different machines in order to see requests hitting distinct slaves.I unfortunately had to drop support for showing the number of connected users in the chat room. In Socket.IO 1.2.0 there will be support for listing the number of connected clients, and therefore being able to get the count (#1630 (comment)).
I would love some feedback from the project maintainers about how I did on using cluster, and whether my solution is in-line with their vision on the best practice for scaling Socket.io across multiple nodes.