Riz
Riz

Reputation: 6676

how to fix slow loading actions in asp.net mvc on azure web apps

We have notice a huge performance impact on our asp.net mvc application since we moved to azure web apps. One thing we've noticed is that request times slow down significantly when an action is loaded the first time in a couple hours. Our app is not used a lot so there's a lot of idle time. I'll give a few examples (please note these are just back-end request response times, and exclude dom, js, image, etc. load times):

  1. user dashboard - first request will take around 20 seconds. Subsequent loads are around 1 second
  2. loading some object - first request will be around 7 seconds. refreshing will get you around 2 secs. loading other objects using same action is also faster after that action is hit the first time

I realize that some of the speed up might be due to query caching, but I am wondering if that's all. I am on a standard plan and do have "Always On" enabled, so I know that's not the issue. And this seems to be happening per action. So even if the user visited action1 already and now visits action2 for the first time, they'll still experience slowness.

What can I look for here to fix? Are there any azure specific settings?

Upvotes: 1

Views: 1502

Answers (2)

Fei Han
Fei Han

Reputation: 27793

One thing we've noticed is that request times slow down significantly when an action is loaded the first time in a couple hours.

As you did, enabling “Always On” setting on Azure web app can increase application responsiveness, especially if application is not very frequently accessed by users.

these are just back-end request response times, and exclude dom, js, image, etc. load times

Please check the code logic of those actions and make sure the code is efficient. Besides, you can try to specify custom initialization/warm-up actions for those pages (that always take long response time when the first time client browse the page). If possible, you can cache the frequently used data instead of retrieving data from database (or other sources) every time client browse the web page.

<system.webServer>
  <applicationInitialization doAppInitAfterRestart="true">
    <add initializationPage="/Home/Contact" hostName="appname.azurewebsites.net" />
  </applicationInitialization>
</system.webServer>

Upvotes: 2

Alberto Morillo
Alberto Morillo

Reputation: 15608

Please run your query as shown below:

`--your query goes here

go

select * from sys.dm_exec_session_wait_stats where session_id = @@spid order by wait_time_ms desc `

The last SELECT statement will provide us the cause it takes so much time to run the first time.

It could be poor IO performance on large queries running on lower tiers.

Hope this helps.

Upvotes: 2

Related Questions