Course contentsShow
← C#
Lesson 1452 of 1,90813. Real-time Communication with SignalRFree lesson

Scaling with Redis Backplane

Coordinate multiple server instances to deliver messages to clients connected to different nodes.

In this lesson, you will learn how to synchronize real-time messages across multiple server instances using a Redis backplane to ensure every connected client receives the correct data regardless of which server they are physically connected to.

The Problem: Server Silos

When you scale your application horizontally, you deploy multiple server instances behind a load balancer. SignalR manages connections in memory. If Client A is connected to Server 1 and Client B is connected to Server 2, Server 1 has no inherent knowledge of Client B. If you call Clients.All.SendAsync(...) from Server 1, only the clients physically attached to that specific instance receive the message. This creates a "silo" effect that breaks your real-time features.

The Solution: The Redis Backplane

The Redis backplane acts as a high-speed message broker that sits between your server instances. When a message is broadcast from one server, it is published to a shared Redis channel. Every other server instance in your farm subscribes to this channel. When a server receives a message from Redis, it then forwards that message to the clients connected to its own local memory.

To implement this, you install the Microsoft.AspNetCore.SignalR.StackExchangeRedis NuGet package and configure it in your Program.cs:

builder.Services.AddSignalR()
    .AddStackExchangeRedis("your-redis-connection-string", options => {
        options.Configuration.ChannelPrefix = "MyAppBackplane";
    });

How it Orchestrates

  1. Broadcast: You trigger a Clients.All call on Server 1.
  2. Pub/Sub: SignalR serializes the message and pushes it to a Redis topic.
  3. Distribution: Servers 2 and 3, subscribed to that Redis topic, receive the notification.
  4. Local Delivery: Each server examines its own list of connected clients and invokes the client-side method locally.

By moving the "source of truth" for message distribution to an external, shared memory store, you maintain the appearance of a single, unified server instance, even if you are running dozens of nodes.

Key Takeaway: A Redis backplane acts as a message bus that enables horizontal scaling by synchronizing Hub broadcasts across all distributed server instances, ensuring that no client misses a message regardless of their connection node.