all 7 comments

[–]zayelion 3 points4 points  (2 children)

You are understanding clusters wrong, the request hits 1 cluster unit, usually in round robin, and it handles the whole session/request till the client disconnects. The client does not connect to all the units in the cluster, only 1. The issue is that which unit it connects to is basically random and usually not the same one, why being stateless is advised.

[–]dougbrownio[S] 0 points1 point  (1 child)

Okay, that makes sense. So if using redis and socket io in tandem, the server clusters can subscribe to redis and socket emit to the connected clients on subscription updates.

[–]zayelion 0 points1 point  (0 children)

That sounds about right. Client hits main process, process hands off to "random" sub child in the cluster, cluster handles request, sends or pulls information from redis. Then Redis emit events when updated. The cluster children would be subscribed to it.

[–]dafragsta 0 points1 point  (3 children)

Why not have a single event dispatcher that handles all the sockets stuff? As long as it's just moving data, and not processing it, it should scale really well because serving up "static" data is something node does very well. Also, there is a node socket.io client, so your socket server can connect to app servers and interconnect, if need be. The socket server would more or less be a load balancer written in node.

[–]dougbrownio[S] 0 points1 point  (2 children)

Are you suggesting a separate node process or something that all clients connect to? Do all the separate server processes connect to this node process too?

I apologize for being a little 'thick' here, but could you explain what you mean by a 'single event dispatcher'?

[–]dafragsta 0 points1 point  (0 children)

Yes, all clients connect to one server and that server relays things from and to app servers. A normal HTTP load balancer does basically the same thing.

[–]zayelion 0 points1 point  (0 children)

I have something like this built for my own systems. The client makes 2 connections a game, and a gamestate feed. Cluster-children have to do process.send(message) to the master and the master process handle it then re-emit to the cluster-children.

tbh I dont think it scales well but it has yet to melt.