1

We have a load balanced webserver setup and we therefore want to use SignalR for client/server communication with a SignalR backplane.

How can we make sure that only one server writes to the database when a client sends something to the server? The backplane will re-route the message to all servers, but not all servers can write the same thing to the DB!

Any techniques/suggestions for how I can both use the SignalR backplane and only write to DB from one server?

In my ideal world I would receive the message on one server, store message to DB and then put a message (maybe not the same as the incoming message) on to the backplane.

x3m
  • 533
  • 5
  • 16
  • If a client sends something to a server, wouldn't only one server be handling any given message? How is there a risk of all servers writing the same thing to the DB in this scenario? – halter73 Sep 23 '14 at 19:08
  • The SignalR backplane will forward the message to all servers, i.e. not only to the server that first receives the message from the client. And I don't think there is a way for the servers to know if the message originated to them and therefore they won't know who should write to the DB. – x3m Sep 24 '14 at 06:16
  • The SignalR backplane only forwards messages sent *from the server to client* to all servers. This is done so SignalR can ensure messages will get to their intended client(s) even if they hop servers. When a SignalR client invokes a Hub method, the Hub method is only invoked on one server even if there are multiple SignalR servers behind a load balancer communicating via a backplane. – halter73 Sep 24 '14 at 18:14
  • OK, I've misunderstood the use of the backplane! Do you want to write some kind of answer explaining this? So that my original question gets an answer. :) – x3m Oct 02 '14 at 14:06

1 Answers1

2

The SignalR backplane only forwards messages sent from the server to client to all servers. This is done so SignalR can ensure messages will get to their intended client(s) even if they are connected to another server.

When a SignalR client invokes a Hub method, the Hub method is only invoked on one server even if there are multiple SignalR servers behind a load balancer communicating via a backplane.

halter73
  • 15,059
  • 3
  • 49
  • 60