4

Today my web application (ASP.NET MVC4) is running only once (1 instance).
If an action needs to push something to all clients, I do it in this way:

  public ActionResult SomeAction(...) 
  {
     // Stuff happenning here...
     // ...

     // Push notify
     var hubContext = GlobalHost.ConnectionManager.GetHubContext<MyHub>();
     hubContext.Clients.Group("SomeGroup").pushSomething();
  }

Now my web application needs to run in multiple instances, with a load balancer that redirects the users to different instances of the same application.

A client could be using http://someIPAddress or http://otherIPAddress and it should feel and be the same for the client.

The question is, how do I use SignalR in this case? with multiple hubs

I suppose it is something like the following:

  public ActionResult SomeAction(...) 
  {
     // Stuff happenning here...
     // ...

     // Push notify
     foreach (var hub ....)  // <-- This!
           hubContext.Clients.Group("SomeGroup").pushSomething();
  }

But I'm not sure.

Other information: this app is running in Windows Azure, and the "instances" will be defined by the "Azure web site number of instances"

sports
  • 7,851
  • 14
  • 72
  • 129
  • 4
    There's an entire section of the documentation that discusses [Scaleout in SignalR](http://www.asp.net/signalr/overview/signalr-20/performance-and-scaling/scaleout-in-signalr) – Damien_The_Unbeliever Mar 10 '14 at 13:08
  • @Damien_The_Unbeliever should be an answer instead of a comment, right? or a flag? – Mahmoud Darwish Mar 11 '14 at 06:45
  • 1
    @MEYWD - it shouldn't be an answer because all I'm doing is signposting to the documentation. And I can't find a close reason (any more) of "obviously hasn't even bothered to look at the documentation". – Damien_The_Unbeliever Mar 11 '14 at 06:54
  • @Damien_The_Unbeliever maybe a "need moderator attention"? – Mahmoud Darwish Mar 11 '14 at 06:56
  • If there is no close reason of "obviously hasn't even bothered to look at the documentation" then the question is completly valid. Also, my question gives good search queries to stackoverflow itself. Regarding the question/answer: the documentation says one can use either Redis, SQL Server or Azure Service Bus, for scaling out. A good answer could contain opinions on these alternatives (documentation doesnt, and thats the difference between reading an answer here and reading the documentation) – sports Mar 11 '14 at 16:40
  • @sports ["primarily opinion-based - discussions focused on diverse opinions are great, but they just don't fit our format well."](http://stackoverflow.com/help/closed-questions) – Mahmoud Darwish Mar 12 '14 at 12:01

0 Answers0