The moment that you start using SignalR, better sooner than late you should add a backplane to allow scaling out your backend services. At the moment of writing I’m aware of only 2 possible backplanes:
- The Azure SignalR service: in this case you are moving your full SignalR backend logic to Azure. Azure will manage the scale out for you.
- Redis backplane: in this case you are still running the SignalR backend yourself and only the data is replicated through Redis
In their official documentation Microsoft refers to the Microsoft.AspNetCore.SignalR.StackExchangeRedis nuget package, but I’m using the (official?) Microsoft.AspNetCore.SignalR.Redis package.
Here are the steps you need to take to use it:
- Add the Microsoft.AspNetCore.SignalR.Redis package to your ASP.NET Core project.
- In your startup class add the AddRedis line to your SignalR middleware configuration:
- Add the Redis connectionstring to your configuration.
- That’s all!
Remark: Don’t forget to enable sticky sessions when you are doing a SignalR scale-out.