Search code examples
silverlightsignalrscalingnlb

SignalR - NLB Server Change and Suggested Way to Scale-Out


I have silverlight web app. This web app run in 4 servers with a NLB in front of them. I need to use SignalR in my web app.

Lets think about this scenario. Client#1 is connected to Server#1 and everything is okay. They are communicating each other through a hub perfectly. Then suddenly NLB assigned Client#1 to Server#2.

Now, what will happen to Connection and Hub? How they will communicate? How is the connection between Client#1 and Server#1 set?

PS: I don't know much about NLB. Maybe it is stupid question, but I could not find a good explanation.

My second question is, which way among scaling out (Azure, SQL, Redis) is the best for .NET Silverlight app with possibly not many clients (Less than 10K)?

Not: I use MS SQL, SQL Server highly in my app.


Solution

  • After I watch this very informative video, I found answers to my questions.

    Basically, the new connection will be established automatically when the client is assigned to other server node. The old connection is lost, however in any case, all the clients can be notified if you are using Back-plane. Thus, this is not a problem.

    The hub object is also not a problem since it is transient object, i.e, in every new single operation a new hub object is created. Thus, this is also not a problem. There is no persistent hub object between server and client. Even if there is one server and one client, the hub will be destroyed and created in every operation.

    The only problem is that if you are using groups, then the group information is lost for the client when it connects to the other server. The server does not maintain lists of groups or group memberships. So in that case you need to use a database and you can update manually from your db. When the new connection is establishes between client and new server, you can search this client in the db, and if you find a group information of that client, then you can manually re-register to that group again.

    For choosing the Backplane, there is no fastest or best way. Nobody can say this way is faster or better among Azure Service Bus, Redis, SQL. It really depends on your application. If you are already using MS Azure Services, then pick Azure implementation for your web app. If you are using Redis in you app, go woth Redis. Otherwise you can select SQL. As I said, all of them are more or less same. Pick one that is most suitable for your web app.

    These are all what get from video and the official site of the SignalR page. This site is one of the best SignalR tutorial and api guide site. It is highly recommended that go through all sections.