Cookie Consent by Free Privacy Policy Generator SignalR Backplane for ASP.NET Core - NCache

SignalR Backplane for ASP.NET Core

NCache acts as a high-performance SignalR Backplane for ASP.NET Core, enabling real-time web applications to scale linearly across multi-server web farms without performance bottlenecks. 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, live financial dashboards, collaborative whiteboards, auction apps, and social media networks, as well as 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.

NCache SignalR Backplane architecture showing Pub/Sub message broadcasting across a load-balanced web farm.
Figure 1: Real-time message distribution flow using NCache as a SignalR Backplane.
 

Using NCache as SignalR Backplane

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:

  1. Install the NCache SignalR NuGet Package

    Add the NCache SignalR NuGet Package to your project:

    Install-Package AspNetCore.SignalR.NCache
  2. Modify appsettings.json

    Modify your NCache configuration settings in the appsettings.json file:

    {
      "NCacheConfiguration": {
        "CacheName": "demoCache",
        "EventKey": "chat",
      }
    }
  3. Register NCache as a SignalR Backplane

    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();
 

Why Use NCache as SignalR Backplane?

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. Unlike SQL Server backplanes, which can become a bottleneck due to database locking, NCache uses in-memory distribution to eliminate latency. Furthermore, being native .NET, it avoids the serialization overhead often found in non-native solutions like Redis. NCache stands out as a powerful .NET Distributed Cache available and offers the following benefits:

  1. Eliminate Delivery Delays with .NET Pub/Sub Messaging: NCache offers Publish/Subscribe (Pub/Sub) messaging capabilities, which are used by SignalR Backplane to distribute messages effectively across multiple web servers in a multi-node environment.
  2. Support for Groups and Users: NCache allows sending messages to SignalR groups, which are collections of related connections. It also gives you the ability to send targeted messages to all connections linked with a specific SignalR user.
  3. 100% .NET Native Cache: Unlike other caching solutions that were originally developed in C++ and later adapted for Windows, NCache is natively built for .NET. This ensures smooth compatibility and a fully integrated experience with ASP.NET Core applications.
  4. Extremely Fast & Scalable: Since NCache is an in-memory distributed cache, it significantly lowers latency and ensures linear scalability. This allows applications to handle a high volume of message throughput without any performance bottlenecks.
  5. High Availability and Data Reliability: NCache offers a self-healing peer-to-peer clustering architecture with no single point of failure. It also includes smart data replication to prevent data loss if a cache server goes down while keeping replication costs low.
  6. Deployment Flexibility: NCache fits seamlessly into any environment, supporting Docker (Windows & Linux containers), Kubernetes, Red Hat OpenShift, Azure, AWS, and Google Cloud deployments, as well as on-premises Windows/Linux servers.

What to Do Next?

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.

Frequently Asked Questions (FAQ)

In a multi-server web farm, client connections are isolated to specific servers. Without a backplane, messages sent on one server cannot reach clients on another. NCache acts as a Pub/Sub message broker, instantly distributing messages across all servers to ensure real-time synchronization for all users.

Unlike Redis, which is Linux-based, NCache is 100% Native .NET. This eliminates the overhead of interop serialization and allows NCache to fit seamlessly into your existing .NET stack without requiring separate Linux environments or complex clustering configurations.

Server-side integration is minimal: simply install the AspNetCore.SignalR.NCache NuGet package and add a configuration block to appsettings.json. Crucially, zero changes are required for your client-side code (JavaScript/Blazor), making migration effortless.

© Copyright Alachisoft 2002 - . All rights reserved. NCache is a registered trademark of Diyatech Corp.