闲置一段时间后,Azure应用程序服务网站的响应时间很慢 [英] Azure app service websites has slow response times after being idle for some time

查看:164
本文介绍了闲置一段时间后,Azure应用程序服务网站的响应时间很慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在过去的几周中,我们一直在调查一些性能问题,其中我们的MVC应用程序对第​​一个请求的响应非常慢.对于第一个请求,我们正在谈论30-45秒,对于每个新视图,我们正在谈论3秒.我们的MVC应用程序正在使用位于同一服务器上的OData API(Web API).除了与MVC应用程序相同的性能问题外,对实体框架版本6的第一个查询在6秒内执行,而新查询的执行速度比后续查询慢200毫秒.

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.

为了满足我们的要求,我们选择执行所有已知的Ef查询,并从Global.asax中的Application_Start命中所有MVC/API端点.这似乎可以正常工作至少两个小时,但是一段时间不使用后,对每个MVC视图的第一个请求将在3-5秒内响应.

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.

我们已将网站配置为始终在线",并且在IIS日志或添加到Application_Start的日志中未找到任何内容.因此,看来我们的应用程序至少没有回收.我怀疑某种IIS缓存已清除,或者某些Ef缓存?欢迎任何建议.

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.

推荐答案

您将要为Web应用启用始终在线"设置.

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

您可以从portal.azure.com->您网站的刀片服务器->所有设置->应用程序设置->始终打开

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

有关详细信息,请参见此处: https://azure. microsoft.com/en-us/documentation/articles/web-sites-configure/

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

禁用始终在线"后,闲置20分钟后,该站点将被关闭,以释放资源以供可能在同一App Service计划上运行的任何其他站点使用.

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.

这篇关于闲置一段时间后,Azure应用程序服务网站的响应时间很慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆