aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

better blazor scale-out documentation

Open schmitch opened this issue 6 years ago • 13 comments

currently our company want's to scale-out blazor a little bit, however the documentation is really lacking, especially what happens if redis/azure signalr services is used as a backend.

I mean currently SignalR itself can be configured without sticky sessions and redis. However there is nearly no documentation, if something like that can be done with blazor.

Also what happens in case of a server failure, can a secon server take over the work when signalr runs with a redis backing store? or does blazor still keep everything in memory?

schmitch avatar Dec 20 '19 11:12 schmitch

@schmitch there's a fair bit of documentation about deploying Blazor with Azure SignalR Service here: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/blazor/server?view=aspnetcore-3.1#signalr-configuration which states that sticky sessions are required. https://docs.microsoft.com/en-us/aspnet/core/blazor/state-management?view=aspnetcore-3.1 also covers some details about how to effectively manage state with multiservers.

Do these documents cover your questions?

pranavkm avatar Dec 20 '19 18:12 pranavkm

I'm in the same boat as @schmitch. I have read that sticky sessions are not required when using Redis and if the only transport is WebSockets, but this appears to require client-side configuration. I can't see any documentation about whether this is possible to configure with Blazor.

I've implemented custom state management for ephemeral state, but this isn't really the issue.

What I'm looking for is a practical guide on how to redeploy or upgrade nodes in a multi-node cluster without the "Could not reconnect to the server. Reload the page to restore functionality." error being displayed to end users.

I was assuming - perhaps naively, having not played with SignalR before - that I could use a Redis backplane, somehow disable the need for sticky sessions, and all state is replicated across servers.

I modified ConfigureServices to add Redis support to SignalR:

services.AddServerSideBlazor();
services.AddSignalR().AddStackExchangeRedis(...);

I can see pub/sub channels created, but I can't see any messages being sent. Should there be?

tl;dr - how is one supposed to scale out Blazor applications, not use Azure SignalR Service, and maintain zero-downtime for end users? The state management page is only part of the puzzle, and that seems a fairly straightforward one to address.

nullpainter avatar Feb 16 '20 01:02 nullpainter

This is a similar question to #9734, with the same state management page discussed, however this doesn't address that poster's concerns either.

It's straightforward to persist application state (view models etc.) via an ad-hoc state manager, but what is resulting in the 'could not reconnect' message? Is there some way to implement a non ad-hoc manager - i.e. some sort of state manager registered with Blazor - so Blazor automatically reconnects?

I assumed this message was relating to the SignalR connection being broken, so I'm confused why the state management page keeps being referenced.

nullpainter avatar Feb 16 '20 01:02 nullpainter

Or is the message that SignalR terminations are unavoidable, and that the Blazor approach is for the developer to to maintain state as per ASP.NET Core Blazor state management?

nullpainter avatar Feb 16 '20 19:02 nullpainter

I also have come across the same issue. It's impossible to update a blazor server side app without all connected clients receiving the connection disconnected message - which I understand why, but I'd really like a workaround.

The same thing also happens when you use Azure Deployment slots and using Azure SignalR service, as ultimately the signalr circuit is being lost.

Your idea of using Redis for the signalr connections would have been great if that worked. Is it possible for that to be implemented?

@danroth27 can the client circuit object be serialized?

physix99 avatar Sep 04 '20 13:09 physix99

@physix99 There are a number of different ways you can handle persisting the app state for a given client: https://docs.microsoft.com/aspnet/core/blazor/state-management?pivots=server In .NET 5, the support for using protected browser storage will be built in to the framework.

danroth27 avatar Sep 04 '20 15:09 danroth27

@danroth27 Thanks Dan for your reply.

What I was actually referring to was serializing the signalr client object for Blazor Server. Which is what i believe contains all the information about the client (e.g. information needed to render the DOM).

What i'm after is being able to have 2 back end blazor servers for load balancing. Azure Signalr service in front of them - sticky sessions turned off.

Then if we need to update the blazor server application, we can do 1 server. All the signalr connections to that server will be dropped, but Azure will automatically join them to the other server. Because the Blazor Server circuit has been serialised between the two (using whatever mechanism needed), the client will join to the remaining online server with a very minimal reconnecting screen.

Obviously if there has been big changes the client will need to refresh the page to remake the connection, but for all major changes it should be good enough?

Thanks

physix99 avatar Sep 08 '20 07:09 physix99

Thank you for contacting us. Due to a lack of activity on this discussion issue we're closing it in an effort to keep our backlog clean. If you believe there is a concern related to the ASP.NET Core framework, which hasn't been addressed yet, please file a new issue.

This issue will be locked after 30 more days of inactivity. If you still wish to discuss this subject after then, please create a new issue!

ghost avatar Dec 08 '20 14:12 ghost

Thanks for contacting us. We're moving this issue to the Next sprint planning milestone for future evaluation / consideration. We will evaluate the request when we are planning the work for the next milestone. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

ghost avatar Dec 08 '20 17:12 ghost

Reopening to document this.

mkArtakMSFT avatar Dec 08 '20 17:12 mkArtakMSFT

To summarize this: If there is Redis server and clients connect with SignalR only via WebSockets, Blazor Server-Side application is properly scaled-out (and therefore no need for Sticky Sessions), right?

leonkosak avatar Jan 13 '21 06:01 leonkosak

Adding to this: It would be great to see examples of typical HA scenarios or documentation that helps describe what needs to be done to achieve HA. For example, clear practical guidance on how to get clients re-connected in situations where code is being deployed would be great (the pathways to leverage slots for deployments for example for Blazor Server w/ Azure SignalR, or SignalR + Redis)

runtimeware avatar May 05 '22 23:05 runtimeware

Thanks for contacting us.

We're moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

ghost avatar Nov 21 '22 23:11 ghost

I'm trying to find out scalability limitations for blazor server in order to decide whether I'm better off with blazor wasm and explicit websocket communication, for an app that requires real time communication, using some external API Gateway (e.g: AWS Api Gateway with websocket support) to keep as many websocket connections open as needed.

Where could I find answers to this? Would vertical scalability in Blazor Server app's machine solve the need for an external API Gateway? Would horizontal scalability (a second instance of blazor server app) cause connectivity issues to clients?

It'd be great to read better documentation about it (happy to read your suggestions).

diegosasw avatar Jan 08 '23 16:01 diegosasw

I'm trying to find out scalability limitations for blazor server in order to decide whether I'm better off with blazor wasm and explicit websocket communication, for an app that requires real time communication

@diegosasw It depends on how much real time communication you need. If it's fairly limited, then you will likely get some scale out benefits from using Blazor WebAssembly. By comparison, Blazor Server requires an active real time connection to even function.

using some external API Gateway (e.g: AWS Api Gateway with websocket support) to keep as many websocket connections open as needed.

The Azure SignalR Service is specifically designed to handle connection scaleout.

Would vertical scalability in Blazor Server app's machine solve the need for an external API Gateway?

Possibly. It depends on how many concurrent users you need to be able to handle and how many concurrent connections the server can handle.

Would horizontal scalability (a second instance of blazor server app) cause connectivity issues to clients?

It shouldn't as long as you setup sticky sessions so that clients reconnect to the same server instance.

danroth27 avatar Jan 09 '23 19:01 danroth27

Btw in this issue it was basically answered: https://github.com/dotnet/aspnetcore/issues/38611#issuecomment-982028457 thus blazor always needs stickey sessions since it never uses the redis backend

schmitch avatar Aug 02 '23 21:08 schmitch

Thanks for contacting us.

We're moving this issue to the .NET 9 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

ghost avatar Oct 06 '23 17:10 ghost

Just trying to work out some issues using blazor in my organization.

Is there any reason why blazor server doesn't support using redis as a backplane, when a vanilla signalr connection does support it?

Seems like it would be a nice feature.

maxsargentdev avatar Nov 17 '23 18:11 maxsargentdev

Thanks for contacting us.

We're moving this issue to the .NET 9 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s). If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

ghost avatar Dec 12 '23 18:12 ghost

Currently, Blazor Server does not support cloud native. To support autoscaling, the architecture must be able to scale out and scale in. We recognize that we cannot safely scale in. I would like you to respond as soon as possible.

n2029-ndensan avatar Apr 24 '24 23:04 n2029-ndensan