[英]Microsoft azure app service(MVC C# Web API) getting sleep if there is no action in some interval time
We have use Microsoft Azure shared web api hosting, but it getting sleep if there is no actions in that api(no api call from mobile app in some interval time), 我们已经使用了Microsoft Azure共享网络api托管,但是如果该api中没有任何操作(在一段时间间隔内没有来自移动应用的api调用),它将进入睡眠状态,
Once it getting sleep then it will take long time for give the response. 一旦入睡,将需要很长时间做出响应。
usually one api is give response in 125 milliseconds but long time no action in between the api and mobile app it will getting sleep, that time the same api take 2 minutes for give response or give the timeout exception. 通常一个API会在125毫秒内做出响应,但是很长一段时间之后,该api和移动应用之间都没有任何动作,它会进入睡眠状态,而同一个api则需要2分钟才能做出响应或给出超时异常。
App engine running in Share hosting model 以共享托管模式运行的App引擎
How to resolve that, Please help me. 如何解决该问题,请帮助我。
This is 'by design' for the Shared App Service. 这是共享应用程序服务的“设计使然”。 If you want to use Always on, move to Basic (or higher) tier.
如果要使用始终启用,请移至基本(或更高)层。
Always On.
永远在线。
By default, web apps are unloaded if they are idle for some period of time.默认情况下,如果Web应用程序闲置了一段时间,则会将其卸载。 This lets the system conserve resources.
这样可以节省系统资源。 In Basic or Standard mode, you can enable Always On to keep the app loaded all the time.
在“基本”或“标准”模式下,可以启用“始终打开”以始终保持应用程序加载。 If your app runs continuous WebJobs or runs WebJobs triggered using a CRON expression, you should enable Always On, or the web jobs may not run reliably.
如果您的应用程序运行连续WebJobs或运行使用CRON表达式触发的WebJobs,则应启用Always On,否则Web作业可能无法可靠运行。
Source: Configure web apps in Azure App Service 来源: 在Azure App Service中配置Web应用程序
This is standard behavior for Shared pricing tiers. 这是共享定价层的标准行为。 If you want your app to keep alive you need Always on enabled which is available starting from Basic pricing.
如果您希望您的应用保持运行状态,则需要启用“ 始终启用”功能,该功能可从基本定价开始使用。 Otherwise app pool will be always recycled after some period of inactivity (about 21 minutes).
否则,闲置一段时间(约21分钟)后,应用程序池将始终被回收。
If your application uses Application Insights , you could configure a ping test to ensure your API stays warm (the Always On feature basically does the same). 如果您的应用程序使用Application Insights ,则可以配置ping测试以确保您的API保持热状态(“始终开启”功能基本上是相同的)。 Alternative you could use Azure Scheduler to invoke your API periodically.
或者,您可以使用Azure Scheduler定期调用您的API。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.