Let's say I've got 2 Stock ticker servers that're pushing quotes to web browser clients. the 2 servers sits behind a load balancer (Round Robin mode). consider the following scenario:
client A subscribe to Google stock on Server1 like so: Groups.Add(Context.ConnectionId, "Google");
client B subscribe to Yahoo stock on Server2:Groups.Add(Context.ConnectionId, "Yahoo");
client C subscribe to Google stock on Server2:Groups.Add(Context.ConnectionId, "Google");
Now both servers are already synced with the stock market so when a stock gets updated they both get the update at real time.
my question is:
when server2 push a new update like so:
Clients.Group("Google").tick(quote);
who are the clients it will send the message to? will it always be client C? I guess not, we have a load balancer in between so the connected clients at a given time may change, right? it may me C now, but next tick it can be clients A&C or only A. A web sockets's connection suppose to stay open so how does the load balancer will handle that, will it always forward the connection from 1 client to a specific server?
backplane won't help me here, because my 2 servers already synced and will send the same messages at the same time. so if I'll force them to route their messages through the backplane to the other server it will end up with duplicate messages to the clients like so:
server1 gets ticker X to Google at 10:00 --> route to backplane --> route to server 2 server2 gets ticker X to Google at 10:00--> route to backplane --> route to server 1
server 1 sends 2 X Google tickers to his clients server 2 sends 2 X Google tickers to his clients
OK, eventually I have synced all group subscriptions thorugh a shared cache (Redis) so all servers knows all users and their subsciptions. this way each server will know his current clients registerd groups, and will push the relevant data.
Update:
After much thought this is what we've ended up doing: