Real-time ASP.NET Core SignalR applications rely on the distribution of messages across servers for high-frequency updates. Examples of such applications include online games or social media networks, as well as live dashboards and other similar platforms where real-time interaction is key. To ensure seamless scalability in a multi-server environment, SignalR relies on a backplane mechanism to distribute messages effectively. NCache offers a powerful and scalable SignalR Backplane for this purpose.
NCache is a distributed caching solution that works seamlessly with ASP.NET Core SignalR to support real-time web applications, running in load-balanced multi-server environments for effective scalability and performance boosts. NCache also provides advanced Pub/Sub messaging features to help SignalR distribute messages efficiently across multiple servers.
You can configure your ASP.NET Core application to utilize NCache as a SignalR Backplane for high scalability and smooth message distribution. The process of integrating NCache as a SignalR Backplane is simple. It involves just a few configuration steps as outlined below:
Add the NCache SignalR NuGet Package to your project:
Install-Package AspNetCore.SignalR.NCache
Modify your NCache configuration settings in the appsettings.json file:
{
"NCacheConfiguration": {
"CacheName": "demoCache",
"EventKey": "chat",
}
}
Modify Program.cs to configure SignalR to use NCache as a backplane:
using Alachisoft.NCache.AspNetCore.SignalR;
var builder = WebApplication.CreateBuilder(args);
// Bind NCache configuration section
builder.Services.Configure<NCacheConfiguration>(
builder.Configuration.GetSection("NCacheConfiguration"));
// Register SignalR with NCache backplane
builder.Services.AddSignalR().AddNCache(ncacheOptions =>
{
ncacheOptions.CacheName = builder.Configuration["NCacheConfiguration:CacheName"];
ncacheOptions. EventKey = builder.Configuration["NCacheConfiguration: EventKey"];
});
var app = builder.Build();
// Map your SignalR hub endpoint directly
app.MapHub<YourSignalRHub>("/your-hub");
app.Run();
If your ASP.NET Core application experiences high traffic and operates in a load-balanced multi-server web farm, then you should consider integrating NCache as your SignalR Backplane solution. NCache stands out as a powerful .NET Distributed Cache available and offers the following benefits:
Explore more about NCache and its benefits for ASP.NET Core SignalR applications:
By using NCache, your ASP.NET Core SignalR applications can scale effortlessly while maintaining real-time performance across multiple servers.
© Copyright Alachisoft 2002 - . All rights reserved. NCache is a registered trademark of Diyatech Corp.