Azure app service websites has slow response times after being idle for some time

巧了我就是萌 提交于 2020-07-17 06:11:09

问题


In the last couple of weeks we've been investigating some performance issues where our MVC application was responding very slow for the first request. We are talking like 30-45 seconds for the first request and 3 seconds for each new view. Our MVC application is using our OData API (Web API) which is located on the same server. Besides the same performance issues as the MVC application, the first query to entity framework version 6 is executing in 6 seconds and new queries is executing 200ms slower than subsequent queries.

In order to meet our requirements, we have chosen to execute all known Ef queries and hit all our MVC/API endpoints from Application_Start in Global.asax. This seems to work fine for at least a couple of hours, but after some time without use, the first request to every MVC view is responding in 3-5 seconds.

We have configured the websites to be "Always on" and we have not found anything in the IIS logs or the logging we've added to Application_Start. So it seems our applications are at least not recycling. I suspect some kind of IIS cache being cleared or maybe some Ef cache? Any suggestions are welcome.


回答1:


You'll want to enable the "Always On" setting for your web app.

You can do that from portal.azure.com -> your site's blade -> All Settings -> Application Settings -> Always On

See here for details: https://azure.microsoft.com/en-us/documentation/articles/web-sites-configure/

When Always On is disabled, after 20 minutes of inactivity the site gets taken down in order to free up resources for any other sites that might be running on the same App Service Plan.




回答2:


I've been having the same problem and unfortunately the "Always On" setting is not available on the free and shared pricing tiers. I found an easy way of keeping the Web App warm so it doesn't unload is to set up an Application Insights ping test on a 15 minute interval against the Wep App URL. A walkthrough on how to that can be found here




回答3:


A quick work around can be to create a background Job that will ping you website frequently to avoid the idle state of the webApp.

Or

Try to upgrade the Sql Server db plan & test accordingly.

Good luck & hope this helps.




回答4:


Did you try to investigate this issue by enabling failed request logging?

Azure Portal → your app service → Monitoring → Diagnostics logs → Failed request tracing (On)

I experienced a similar issue that was caused by limiting access to the application using the ipSecurity section in web.config. If you happen to restrict access this way, you need to whitelist the IP of your app service.



来源:https://stackoverflow.com/questions/36115999/azure-app-service-websites-has-slow-response-times-after-being-idle-for-some-tim

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!