go-socket.io icon indicating copy to clipboard operation
go-socket.io copied to clipboard

Scale up

Open rubenv opened this issue 10 years ago • 9 comments

The Node.JS version of socket.io has a concept of a store, to keep track of connections: this allows it to work in a load-balanced setup.

More info here: https://github.com/Automattic/socket.io/wiki/Configuring-Socket.IO#server

Is something similar to this possible with the Go version?

rubenv avatar Jan 27 '15 10:01 rubenv

File the issue too soon (and apparently in the wrong repository).

If I'm not mistaken, serverSessions in https://github.com/googollee/go-engine.io/blob/master/sessions.go takes care of this. This would be the equivalent of MemoryStore.

Would you be open to exposing this interface in the API so that we can plug different implementations (e.g. a Redis store)?

I'm happy to help with this, once I have a bit more spare time.

rubenv avatar Jan 27 '15 11:01 rubenv

How about a interface like ServerSessions or named as something else, and can be set out of library? If not set, it will act as current serverSessions?

googollee avatar Jan 27 '15 11:01 googollee

Yes, exactly that, an interface with a couple of methods, which can be set but which falls back to the default in-memory serverSessions.

It would mean that there is no change required for current users, but makes it possible to scale out.

rubenv avatar Jan 27 '15 12:01 rubenv

Please check the latest code, I add support SetSessionManager. Could you check if it works?

googollee avatar Feb 01 '15 04:02 googollee

Oh wow, thanks! I'll have a look at it, in a week or two. We're currently in the process of launching a new product some time is a bit limited.

Will report back on our experiences once I get round to it. On 1 Feb 2015 05:52, "Googol Lee" [email protected] wrote:

Please check the latest code, I add support SetSessionManager. Could you check if it works?

— Reply to this email directly or view it on GitHub https://github.com/googollee/go-socket.io/issues/64#issuecomment-72351628 .

rubenv avatar Feb 01 '15 10:02 rubenv

@rubenv How are you storing the session object? And how are you reconstructing it when retrieving it?

bigblind avatar Mar 20 '15 23:03 bigblind

Right, forgot about this one.

I'm not sure you can. We had a good look at it, felt that this was going to be a ton of work and realised we didn't need all of this. In the end we opted not to use socket.io and build something simpler/more specialised: https://github.com/rubenv/broadcaster

As for session support here: the objects inside a session aren't really serialisable, so for now I don't think you can.

rubenv avatar Mar 21 '15 08:03 rubenv

Then I wonder what the docs mean when they say a session manager can help you load balance, I'd love to see an example.

bigblind avatar Mar 21 '15 10:03 bigblind

No. I'm sure currently no feature like this. And I still wonder what's the code like about load balance.

googollee avatar Mar 21 '15 17:03 googollee