Skip to content

Minimize Blazor Server state stored per circuit #39882

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 task done
maloo opened this issue Jan 31, 2022 · 1 comment
Closed
1 task done

Minimize Blazor Server state stored per circuit #39882

maloo opened this issue Jan 31, 2022 · 1 comment
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-server ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question Status: Resolved

Comments

@maloo
Copy link

maloo commented Jan 31, 2022

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

According to documentation of Blazor Server each circuit store circuit scoped DI services, component hierarchy, and the latest render of the component hierarchy. From a developer point of view the size of the two former can be controlled by using singleton services, minimal data stored in components etc. But it is much harder to minimize the rendered output (the app needs a specific look). One way is to use web components to minimize the rendered output. But you can only get so far.

Describe the solution you'd like

Would it be possible to use CPU cycles instead of memory to increase the scalability of Blazor Server, that is delete the last rendered hierarchy once sent to the client. On next event/state change, re-render it again from the last state, update the state or handle the event, re-render and send the diff as usual to the client. This would allow each circuit to keep minimal amount of data - just component state.
Maybe even components can be recreated from serialized storage, like a redis cache for ultimate scalability, where you don't even need the node affinity anymore. This would require more user code like a save/load lifetime callback.

Additional context

When you have a public facing web app for presenting lots of common/public/shared data, you really don't want it to be stored in each circuit. Then it is better to take a small re-render/CPU penalty.

@TanayParikh TanayParikh added area-blazor Includes: Blazor, Razor Components feature-blazor-server labels Jan 31, 2022
@javiercn
Copy link
Member

@maloo thanks for contacting us.

It is not generally possible to do so for a simple reason, renders are not guaranteed to be pure functions that are free of side effects, so we need to keep the previous render tree around to be able to diff the components efficiently.

In addition to that, the diffing algorithm that we use is the same for all blazor flavors, we wouldn't want to make a flavor specific version as it would make things like performance way harder to analyze and would likely introduce subtle bugs across server, wasm, desktop.

We do have a feature that tackles improved scalability for Blazor Server, where the idea is that we give you the ability to "pause" a circuit, which will effectively serialize all its state into storage, and the ability to resume it after it has been paused. I'm going to close this issue and would suggest you up-vote that issue instead.

#27576

@javiercn javiercn added ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question labels Jan 31, 2022
@ghost ghost added the Status: Resolved label Jan 31, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Mar 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components feature-blazor-server ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. question Status: Resolved
Projects
None yet
Development

No branches or pull requests

3 participants