socketio / socket.io-cluster-adapter

The Socket.IO official cluster adapter, allowing to broadcast events between several Socket.IO servers.
https://socket.io
MIT License
16 stars 9 forks source link

Possibility of syncing cluster adapter across physical servers #1

Open Interpause opened 3 years ago

Interpause commented 3 years ago

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

Untitled drawing

Interpause commented 3 years ago

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.

darrachequesne commented 3 years ago

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

Interpause commented 3 years ago

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.

alexey-yarmosh commented 1 year ago

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

Interpause commented 1 year ago

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

six-ddc commented 3 weeks ago

Are there any new developments?

Interpause commented 3 weeks ago

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.