1

I am using SignalR hosted in multiple servers behind a load balancer. I am storing the connnection id and the user id in the custom database table in sql server. Every time, I need to send notification to the selected users. It is working fine in the single server environment. How do I scale the SignalR implementation with custom database table without using existing backplane options?

Liudvikas Bukys
  • 5,790
  • 3
  • 25
  • 36
Vijay VSTO
  • 133
  • 1
  • 4
  • 15
  • In your scenario - can you keep all the users that need to talk to each other on one server? – Pawel Dec 20 '16 at 22:35

1 Answers1

0

I am not sure what is your current implementation because it seems to be a bit mixed your explanation. If you have multiple servers behind a load balancer it means you applied some techniques (I think so!). But you said it's working fine in the single server environment but not in multiple servers. Let's review what is mandatory for multiple servers (scale out)

  1. Communication between instances: It means that any message in one instance is available on all the other instances. The classic implementation is any type of queue, SignalR supports Redis, you can use SQL Server but it's clear the limitations of any SQL solution. Azure has a Redis Cache as a PaaS

  2. In-memory storage: You normally use this in a single server but it's mandatory to implement shared memory. Again, Redis has a shared memory solution in case you have the server available. There is not any possibility of implementing this without a solution like Redis. Again, a lower-performance solution would be a MemStorage implementation in SQL.

  3. Authentication: The out-of-the-box implementation of security uses a cookie to store the encrypted key. But once you have multiple servers every server has its unique key. To solve the problem you have to implement your own DataProtector in case this is your method used.

The examples are extremely beyond this explanation, most of the code (even templates without the actual methods implemented) would take several pages. I suggest you to take a look at the 3 items that are mandatory to scale out your application.

Maximiliano Rios
  • 2,196
  • 2
  • 20
  • 34
  • Could you please at least add links on source code or articles or other answered questions about custom backplane implementations? I'm sure there are at least several good things that could really help to the question starter. – cassandrad Dec 27 '16 at 09:43
  • I will add some examples (minimum) that can lead to understand the concept... I've implemented a full solution myself but there is a lot of code. – Maximiliano Rios Dec 27 '16 at 14:02
  • You can provide a link to your repository, then, yes? It will be very helpful for others. – cassandrad Dec 27 '16 at 15:33
  • I'm sorry, I cannot give you access to my repository because I don't own the project and I would have legal issues, that's why I have to create something new and share it. – Maximiliano Rios Dec 27 '16 at 15:43
  • Then your answer does not provide information about how to scale SignalR with custom database. That's what topic starter was asking. – cassandrad Dec 27 '16 at 16:45