SaaS CMS has officially launched! Learn more now.

Performance issues with partial views in CMS

Vote:
 

Hi Team,

I am facing lot of performance issues with Partial views in CMS across the application. This issue is happending only for first request and subsequent requests are very quick. Very simple partial action method also taking min 10+ seconds to load for the first time.

First request issue is for all partial views. Lets say, i have two partial views in two different pages so in every page facing this performance issue.

This issue is happening mutiple times in a day.

Below is one sample examples in controller & views to return the partail view:

return PartialView("~/Views/IndustryPage/_Survey.cshtml", model);

Html.RenderPartial("~/Views/Shared/PagePartials/_Questions.cshtml", Model.Questions);

Below is the custom view engine configured in my application for episerver blocks.

/// <summary>
/// Extends the Razor view engine to include the folders ~/Views/Shared/Blocks/ and ~/Views/Shared/PagePartials/
/// when looking for partial views.
/// </summary>
public class SiteViewEngine : RazorViewEngine
{
private static readonly string[] AdditionalPartialViewFormats = new[] { TemplateCoordinator.BlockFolder + "{0}.cshtml" };

/// <summary>
/// Initializes a new instance of the <see cref="SiteViewEngine"/> class.
/// </summary>
public SiteViewEngine()
{
PartialViewLocationFormats = PartialViewLocationFormats.Union(AdditionalPartialViewFormats).ToArray();
}
}

Can any one help to to fix this issue? This issue is effecting entire application performance. 

Thanks,

Suresh B

#218939
Mar 25, 2020 18:11
Vote:
 

Could some one provide any suggestions on this issue?

Thanks,

Suresh B

#218985
Mar 26, 2020 18:54
Vote:
 

Hi Suresh,

You can try object caching on block levels with the help of the ISynchronizedObjectInstanceCache interface.

Thanks,

Sanjay Kumar

#219061
Mar 28, 2020 16:13
Vote:
 

Hi Suresh,

One thing that slows down the initial (first request) calls is the view compilations as the views need to be compiled (in Episerver we can't use the precompile views optiosn, because it will not work in Episerver projects because Episerver adds programmatically VirtualPathProviders see the answer by Johan).

Without actually knowing what happens in your views - you could be calling tens of other views or the view might be a bad boy and call some services and do heavy work, which could be the slowness issue here. One thing that really can make a difference during view compilation is a slow traditional HDD VS SSD. Real world case of an Azure App Service using traditional HDD the warm  up request took 70 seconds, the App Service plan was changed to one that uses SSD with the same CPU power and initial call dropped to 35 seconds!

So in what kind of environment is this happening if the slowness issue is not in your code? 

#219081
Mar 29, 2020 8:28
Vote:
 

Hi Antti,

Currenlty application is hosted in Episerver DXC. This issue is happening in all three environments(Integration, preproduction & production).

This performance issue is occuring for very simple partal actions as well. Below is one of sample partial action method causing the issue(here I am doing ajax call to load the one of episerver page content using IContentRepository)

public ActionResult UserAcknowlegdePolicy(UserAcknowledgementType userAcknowledgementType)
{
var privacypage = (userAcknowledgementType == UserAcknowledgementType.PrivacyPolicy) ?
_contentRepository.Get<StandardPage>(_siteSettings.SettingsPage.PrivacyPolicy)
: _contentRepository.Get<StandardPage>(_siteSettings.SettingsPage.TermsAndConditions);
UserAcknowledgementViewModel model = new UserAcknowledgementViewModel();
if (privacypage != null)
{
model.MainBody = privacypage.MainBody;
model.Header = privacypage.PageTitle;
}

return PartialView("~/Views/Shared/_UserAcknolegdePolicy.cshtml", model);
}

@model UserAcknowledgementViewModel

<div class="modal-header">
<h5 class="modal-title">@Model.Header</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body bg-light">
<div class="row">
<div class="col-12">
@Html.Raw(Model.MainBody)
</div>
</div>
</div>

Thanks,

Suresh B

#219084
Mar 29, 2020 12:58
Vote:
 

I weould proceed with profiler. Work together with Episerver support to get trave files for the 1st requests. Then you can analyze and see where exactly time is spent. It could zillions of root causes - starting with IO (and as Antti mentioned - access to hard disks) or ending with custom http modules that could be plugged into your request pipeline.

#219114
Mar 30, 2020 6:03
Vote:
 

I have requested to enable profiler but unfortunately it is not tracking those kind of requests. Sometimes noticed below message for few requests 

"50% of this request was spent in waiting. Wait for a resource to be available" but i am not able to dig into more details about this waiting.

For testing, I have created very simple partial request(i.e just return partialview()) and hosted in Episerver integration environment and this request also taking min 10seconds to load for initial request. This issue is happending mutiple times in a day (but not everytime).

Is there any settings which can override compilation debug settings in Episerver DXC? In MVC views renderpath will be cached to improve the render performance. So just thinking this is causing any issue.

And also i have requested epi team to provide report on application recycle so may be my application is recyling multiple times in a day.

What i confused about my issue is, i have custom webpage and it has 10 partial views(i.e. will load on demand) so here sometimes(i.e. may be 2 or 3 times) these 10 requests initial request taking 10+ seconds and subsequenct requests are fine.

Can any one provide suggestions on this to resolve my issue? 

Thanks,

Suresh B

#221526
Apr 20, 2020 16:57
valdis - Apr 21, 2020 10:36
I'm afraid - not (at least without any more detailed dumps and analytics). there could be many reasons for this degradation to happen.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.