为什么Azure应用服务会重新启动

为什么Azure应用服务会重新启动

本文介绍了交换插槽时,为什么Azure应用服务会重新启动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题在生产中已经存在很长时间,并且已经阅读了我能找到的所有内容(例如或或),我做了一个简单的测试.

After having this issue in production for a long time, and having read anything i can find about (such as this or this or that), i made a simple test.

  1. 创建一个空的asp.net网站
  2. 在Application_Start中,向您发送电子邮件或消息(我已经使用过PushBullet),以便您知道应用程序何时启动
  3. 创建新的应用服务计划和资源组
  4. 在Azure上创建网站并发布
  5. 创建临时部署插槽
  6. 交换演出/制作
  7. 再次发布网站,以便两个插槽都具有相同版本的网站

所以我有一个空的网站,没有连接字符串,没有插槽设置:

So i have an empty website, no connectionstring, no slot setting :

当我单击交换时,我将收到有关插槽重新启动的通知(每个插槽至少一次).

When i click swap, I will get notifications that slots restart (at least once each).

为什么会这样?

更新:

研究了Mohit的答案后,我需要进一步澄清.

After studying Mohit's answer, i need some more clarifications.

  • 我们以Application_Start方法发送通知,如果我理解正确,则由AppInit事件触发.

  • We send the notification in the Application_Start method, which is triggered by the AppInit event if i understand correctly.

我不理解您所解释的行为.顺序似乎很重要,以确保不停机,但是您说不一定按顺序进行.为什么需要重新启动生产槽的应用程序域?为什么用户会为该网站关闭而烦恼(应该不会)?

I do not understand the behavior you explain. The order seems very important to ensure no downtime, yet you say it's not necessarily in that order. Why is it required to restart the app domain for the production slot ? Why would users get annoyed that the site is down (it should not) ?

什么是新交换"功能? 旧交换"有什么区别?对于我的测试,我只是使用门户进行了交换.

What is the "new swap" feature ? What's the difference with the "old swap" ? For my tests, i just swapped using the portal.

您提到新交换"在交换之前暂停.我想这只是意味着它正在等待applicationInitialization完成(例如/上的HTTP 200)?

You mention the "new swap" pauses before swap. I suppose it just means it waits for the applicationInitialization to complete (eg HTTP 200 on /) ?

自昨天以来,我还进行了一些测试.在Application_Start方法中,我添加了一些Thread.Sleep来延长应用程序的启动时间.但是,当我调换产品时,无论是分期还是生产,都不会出现停机时间.我是否应该至少在应用程序启动期间经历登台停机时间?这是否意味着预热然后与生产交换的插槽实际上是另一个既不是临时也不是生产的临时插槽?

I've done some more testing since yesterday. In the Application_Start method, i've added some Thread.Sleep to make app startups longer. However, when i swap i see no downtime on either staging or production. Shouldn't i experience downtimes on staging, at least for the duration of my app startup ? Does this mean the slot that is warmed up then swapped with production is in fact another temporary slot that is neither staging nor prod ?

推荐答案

我有一个非常相似的问题,应用程序交换到生产插槽后会重新启动,这会导致不必要的停机时间.经过大量搜索,我发现了以下内容:

I have very similar problem, app is restarted after swapping to production slot and that causes unwanted downtime. After a lot of searching I found the following:

在某些情况下,交换后,生产版位中的Web应用可能稍后会重新启动,而应用所有者没有采取任何措施.当Azure App Service的基础存储基础结构进行某些更改时,通常会发生这种情况.发生这种情况时,应用程序将同时在所有VM上重新启动,这可能会导致冷启动和HTTP请求的高延迟.虽然您无法控制基础存储事件,但是可以将其对生产版位中的应用程序的影响降至最低.在应用程序的每个插槽上设置此应用程序设置:

WEBSITE_ADD_SITENAME_BINDINGS_IN_APPHOST_CONFIG:将其设置为"1"将防止Web应用程序的工作进程和应用程序域在重新配置App Service的存储基础结构时被回收.

您可以找到整个Ruslany帖子,我发现它很有帮助此处

You can find the whole Ruslany post, that I found very helpful here

这篇关于交换插槽时,为什么Azure应用服务会重新启动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 17:45