Minimize Blazor Server state stored per circuit #39882
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
Is there an existing issue for this?
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.
The text was updated successfully, but these errors were encountered: