Clustering and sessions

47 views
Skip to first unread message

mill...@gmail.com

unread,
Aug 17, 2014, 8:16:20 PM8/17/14
to tot...@googlegroups.com
Is it possible to have an example of clustering with http sessions? Like saving http sessions into redis instead of in memory. My main concern http sessions, but also having an example with WebSockets too would be great, I know socket.io has this feature but since you're using your own implementation, this would help immensely.

Peter Širka

unread,
Aug 18, 2014, 6:17:41 AM8/18/14
to tot...@googlegroups.com
Hi,
today maybe tomorrow I'll create some example.

Thanks.

mill...@gmail.com

unread,
Aug 18, 2014, 11:51:08 AM8/18/14
to tot...@googlegroups.com
Thanks! It seems you already show how to use sessions with redis on your main github page. I guess all I need now is clustering with your websockets implementations. Thanks again :)

Peter Širka

unread,
Aug 18, 2014, 4:05:24 PM8/18/14
to tot...@googlegroups.com, mill...@gmail.com

mill...@gmail.com

unread,
Aug 18, 2014, 4:17:29 PM8/18/14
to tot...@googlegroups.com, mill...@gmail.com
You're awesome :) did you decide if you're going to make a websocket clustering example?
Thanks again!

Peter Širka

unread,
Aug 18, 2014, 4:37:24 PM8/18/14
to tot...@googlegroups.com, mill...@gmail.com
Mhhh, cluster and WebSocket ... I think that it's not good idea. Why?
Classic request is a simple communication - client->server->client - close a connection... so if we use a cluster then is everything ok. But problem is in Websocket because websocket works client->server->client AND keep a connection in ONE instance. So cluster does not make a sense in current scenario. Cluster will work, but not according to your idea.

I tested WebSocket performance and here are some results (1 CPU, 2 GB RAM):

Session + Cluster and WebSocket:

Try this route :-)

framework.websocket('/', some_websocket_action, ['#session']);

Thanks.

mill...@gmail.com

unread,
Aug 18, 2014, 4:40:00 PM8/18/14
to tot...@googlegroups.com, mill...@gmail.com
On Monday, August 18, 2014 4:37:24 PM UTC-4, Peter Širka wrote:
> Mhhh, cluster and WebSocket ... I think that it's not good idea. Why?
> Classic request is a simple communication - client->server->client - close a connection... so if we use a cluster then is everything ok. But problem is in Websocket because websocket works client->server->client AND keep a connection in ONE instance. So cluster does not make a sense in current scenario. Cluster will work, but not according to your idea.
>
>
> I tested WebSocket performance and here are some results (1 CPU, 2 GB RAM):
>
>
>
>
> Session + Cluster and WebSocket:
> Try this route :-)
>
>
> framework.websocket('/', some_websocket_action, ['#session']);
>
>
> Thanks.

I only ask because socket.io supports clustering by using a backing datastore (http://socket.io/docs/using-multiple-nodes/) . I know you wrote your own implementation for websockets so I wanted to know if you had something similar

Peter Širka

unread,
Aug 18, 2014, 4:52:23 PM8/18/14
to tot...@googlegroups.com, mill...@gmail.com
Backend implementation of WebSocket in Socket.io is same as total.js. WebSocket wraps server with "sticky session", so this is a key (maybe).


mill...@gmail.com

unread,
Aug 18, 2014, 4:57:19 PM8/18/14
to tot...@googlegroups.com, mill...@gmail.com
On Monday, August 18, 2014 4:52:23 PM UTC-4, Peter Širka wrote:
> Backend implementation of WebSocket in Socket.io is same as total.js. WebSocket wraps server with "sticky session", so this is a key (maybe).

Possibly, but even if a client gets the same instance it last connected to, you still need a way to pass messages to clients on other workers, which is why socket.io has an adapter you can extend/overwrite that you can attach to a database. And each client checks for message periodically or using redis pub/sub.
So it becomes
Client 1(Instance 1) --(Message)--->Redis
Client 2(Instance 2) <----(message)--Redis
Reply all
Reply to author
Forward
0 new messages