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

Possibility of syncing cluster adapter across physical servers

Open Interpause opened this issue 3 years ago • 7 comments

Would a combination of Cluster Adapter and inter-server adapters like Redis Adapter be possible? See diagram below.

Untitled drawing

Interpause avatar Oct 03 '21 01:10 Interpause

I think the easiest way this could be done is by modifying setupPrimary() to further forward inter-process messages using Redis' pub/sub for example. I am currently attempting this.

Interpause avatar Oct 03 '21 02:10 Interpause

So there is only two Redis connections per Server, right? That would be interesting indeed :+1:

darrachequesne avatar Oct 04 '21 09:10 darrachequesne

I managed to get it working. I decided to go with the approach of providing setupPrimary an optional param publish that is used to publish events while returning a listener function that is attached as the subscriber. This would allow the user to implement pub/sub with anything they want besides Redis. Will be testing & perhaps optimizing it when I am free this weekend.

Interpause avatar Oct 04 '21 09:10 Interpause

Hey @Interpause , maybe you can share some results of your tries? Or at least the draft code you got working. Thanks!

alexey-yarmosh avatar Mar 13 '23 07:03 alexey-yarmosh

Sure, here: https://github.com/socketio/socket.io-cluster-adapter/compare/main...Interpause:socket.io-cluster-adapter:inter-server-communication

Interpause avatar Mar 16 '23 02:03 Interpause

Are there any new developments?

six-ddc avatar Sep 12 '24 04:09 six-ddc

Are there any new developments?

Well uni started and I can't remember what I was doing here. I might end up trying the same thing again in the future though if a project calls for it.

Interpause avatar Sep 12 '24 05:09 Interpause