Advertisement
Advanced ASP.NET Core, Blazor Integration with ASP.NET Core

How does Blazor Server's SignalR-based interactivity affect load balancing and horizontal scaling decisions for an ASP.NET Core deployment?

Short answer

Since a Blazor Server circuit maintains persistent server-side state tied to one specific server instance via its SignalR connection, load balancers must be configured for sticky sessions (routing all of a user's requests to the same server instance for the circuit's lifetime)…

Save ASP.NET Core mock interview
Advertisement
AModel answer
Since a Blazor Server circuit maintains persistent server-side state tied to one specific server instance via its SignalR connection, load balancers must be configured for sticky sessions (routing all of a user's requests to the same server instance for the circuit's lifetime), and horizontal scaling requires either sticky-session-aware load balancing or a backplane (like Azure SignalR Service or a Redis-backed SignalR backplane) to allow circuit state to be coordinated across multiple server instances -- a fundamentally different scaling consideration than a typical stateless ASP.NET Core Web API.
// Program.cs: configuring a Redis backplane for SignalR to support Blazor Server scaling
builder.Services.AddSignalR().AddStackExchangeRedis(builder.Configuration.GetConnectionString("Redis"));

// Load balancer configuration (conceptual): enable sticky sessions for the SignalR connection
Real-world example
A Blazor Server application scaling from one to five server instances behind a load balancer requires enabling sticky sessions and adding a Redis-backed SignalR backplane, a deployment complexity that a stateless REST API sibling service never needed to consider.
Likely follow-ups
  • What happens to a user's Blazor Server session if their sticky-session server instance restarts?
  • How does Blazor WebAssembly avoid this scaling consideration entirely?
Related topics