Blazor Server 8 (Circuit / Connection overheads)

106 Views Asked by At

I am trying to get a good understanding of what pressure applies to the server in .NET 8 Blazor and the impact circuits being terminated due to server pressure or inactivity.

Initially I am looking at this for sever rendering (not via web assembly)

So, my understanding is every time Blazor server renders the page it creates/reuses a circuit on the server (same page in 3 tabs, each would each have own circuit)

The circuit contains

1) Any items that have been dependency injected into the rendered page or and subcomponent 

2) The HTML DOM for the page 

3) The values held in any private/public properties on the page 

In addition to the information held in the circuit on the server it also maintaining a connection (so one user with 3 tabs for same page) would have 3 open connections, each frequently sending messages to/from the server.

If this overhead gets too high it could result in circuits terminating which I believe would result in errors for the user when, the impact of which could vary between needing to reload the page or losing unsaved data.

  1. DI

If there are 500 circuits which are alive (user could have loaded page and walked away or browser crashed so not necessarily active in that sense but sever still must maintain until inactivity timeout).

When DI is set to scoped, each instance of the object could have private and public Properties.

I would think it would it just contain 500 copies of these properties; however, I would hope it would not have 500 copies of the code in memory, just one copy of the code that is shared. Would it contain 500 copies of the code or just the public and private property's (which could references to other DI items)?

  1. DOM

Some pages could be large, such as a report showing 2000 rows, effetely the HTML for this would be held in memory per user, per open tab, is this the case and if so, what is advised in this situation.

  1. Private and public Properties in circuit

Taking the example of a report with 2000 rows, when this was a razor page the 2000 rows would be an IEnumeribe

The razor page would render, the server would not need to keep a list of 2000 rows in the HTML DOM (Point 2 above)

The page would also disregard the 2000 rows end in the property "IEnumeribe" once the page is loaded, but I do not believe this would be the case with Blazor

Is this how it works?

If the code were changed to "private IEnumerable< MyDataObject > Rows;" or "private MyDataObject [] Rows;" would this stop this information being held in the circuit as I believe "private IEnumerable< MyDataObject > Rows { get; set; }" would be held in the circuit?

Any information on how this works and advice would be appreciated.

0

There are 0 best solutions below