socket.io-redis-streams-adapter icon indicating copy to clipboard operation
socket.io-redis-streams-adapter copied to clipboard

Load balancing in Redis cluster mode

Open ChoSeoHwan opened this issue 6 months ago • 3 comments

Currently, when using redis-streams-adapter,
it appears that the load is only directed to one master node in the cluster.

If you check the code, it seems that streamName is used as a key for all requests,
and in this case, I know that it is concentrated on only one node according to the redis HashTable.

Is there a way to load balance redis when using this adapter?

At least I think I need to use different nodes for each Room/Namespace.

If there is a way to load balance, please let me know.

ChoSeoHwan avatar May 28 '25 08:05 ChoSeoHwan

Hi!

You are right, there is currently no way to share the load between several primary nodes.

I am open to suggestions on this matter.

darrachequesne avatar May 28 '25 12:05 darrachequesne

What we could do is to have N streams, and hash the namespace to select the stream to use.

This way:

  • the load is divided between the namespaces (not evenly though)
  • message order is still guaranteed

What do you think?

darrachequesne avatar Jun 05 '25 14:06 darrachequesne

Is there any way they can use multiple streams, at least a different stream per namespace or at least group each x rooms and create a stream every x rooms?

DanhezCode avatar Aug 26 '25 23:08 DanhezCode