React.NET icon indicating copy to clipboard operation
React.NET copied to clipboard

Slow view rendering/locks?

Open alkesos84 opened this issue 9 years ago • 2 comments

First: we have happily been using ReactJs.NET in production for a year. We are very pleased so far and would like to thank you Daniel for your great work!

Usage: ASP.NET MVC 5 with ReactJs.NET 2.5.0 (heavy usage of server-side rendering and restricted to V8 javascriptengine)

We have experienced that sometimes the view rendering part takes a very long time. We have been monitoring this for a while and we can see that sometimes (we haven't seen any pattern yet) the view rendering part in the request takes from 8-20 seconds (usually this takes approx 1-2 seconds). We don't have this issue in views where ReactJs.NET is not used. We are using the standard setup and the only change we have done is to set ReactSiteConfiguration.Configuration.SetAllowMsieEngine(false) to force usage of V8 engine.

Could it be that the JsPool is flushed sometimes (or turns into idle mode)? So that those requests that are slow triggers a creation of a brand new engine (which is slow)? The application pool is recycled on a daily schedule so this is not the issue.

Is there anyway to check the pool of JavascriptEngines and make sure that those are always warmed up? If we get rid of the server-side rendering by using "clientOnly: true" on every component, will this skip the usage of the JsPool?

alkesos84 avatar Feb 23 '17 07:02 alkesos84

It's possible you're hitting the MaxUsagesPerEngine and the slowness is the initialization of a brand new engine:

/// <summary>
/// Gets or sets the maximum number of times an engine can be reused before it is disposed.
/// <c>0</c> is unlimited.
/// </summary>
public int MaxUsagesPerEngine { get; set; }

This is set to 100 by default: https://github.com/Daniel15/JSPool/blob/master/src/JSPool/JsPoolConfig.cs#L90. I don't think I expose it as an option in ReactJS.NET, unfortunately. The idea with this is that it helps prevent memory leaks by periodically recycling the engines.

I wonder if JSPool could be cleverer and recycle the engine in the background on a worker thread...

Daniel15 avatar May 12 '17 04:05 Daniel15

Closing out stale issues

Daniel15 avatar Aug 25 '18 19:08 Daniel15