【问题标题】:Azure - Advanced Application restart - access to instance before it's readyAzure - 高级应用程序重启 - 在实例准备好之前访问它
【发布时间】:2019-07-11 11:53:47
【问题描述】:

我有一个在 2 个实例上运行的 Azure 应用服务。我尝试了高级应用程序重启并设置了 90 秒或更长时间的重启延迟。

当其中一个实例重新启动时,客户端请求似乎仍会发送到重新启动的实例。我看到请求需要 60 多秒才能返回。

我原以为当其中一个实例重新启动时,它在准备好处理请求之前将不可用。

如果我需要重新启动其中一个实例,如何确保没有人打扰?

ASP.Net 4.6.1

【问题讨论】:

    标签: azure asp.net-web-api azure-web-app-service azure-app-service-envrmnt


    【解决方案1】:

    Use the AppInit feature :
    
    With the AppInit feature, a new web app instances are added into the rotation, we ensure that the Application Initialization module reports that the site is fully warmed up before sending it a request from the frontend. To use the feature, add an applicationInitialization section to your web.config like so:
     
    <system.webServer>        
      <applicationInitialization remapManagedRequestsTo="/Content/warmup.html"> 
         <add initializationPage="/api/values/100" /> 
      </applicationInitialization>
    </system.webServer>
     
    You can have multiple initialization pages, and the AppInit module will ensure that all of them return 200 before declaring the site officially warmed up. Meanwhile, you can (optionally) use the remapManagedRequestsTo attribute to have a friendly page showing that the site is still warming up.  Thanks to the AppInit feature, this page will not be visible to customers while adding new instances into rotation, however if a process crashes for whatever reason and enters AppInit again, it will come into play.

    默认情况下会为 Azure Web 应用安装应用程序初始化模块。您可以从 web.config 文件或通过 apphost.config XDT 直接配置它。只需在 web 应用程序根目录的 web.config 中添加类似上述内容即可。

    您也可以点击以下链接了解更多信息。 https://docs.microsoft.com/en-us/iis/configuration/system.webserver/applicationinitialization/#configuration

    https://ruslany.net/2015/09/how-to-warm-up-azure-web-app-during-deployment-slots-swap/

    【讨论】:

    • 这很有帮助,但我现在仍然遇到相关问题。我的应用服务有一个虚拟应用程序。虚拟应用程序是面向公众的 Web api 应用程序。当我重新启动主应用程序时,主应用程序正确预热等,但我对虚拟应用程序的请求超时。
    【解决方案2】:

    HTTP 和 HTTPS 探测建立在 TCP 探测之上,并使用指定路径发出 HTTP GET。探针与 HTTP 探针相同,但添加了传输层安全性(TLS,以前称为 SSL)包装器。默认情况下,health probe 每 15 秒尝试检查一次配置的运行状况探测端口。您可以将探测时间减少到 5 秒,如下所示:

    {
        "name": "http",
        "properties": {
        "protocol": "Http",
        "port": 80,
        "requestPath": "/",
        "intervalInSeconds": 5,
        "numberOfProbes": 2
    }
    

    如果你有Application Gateway,你也可以配置它。

    注意:Azure 网站内部会查看整个服务器的健康状况,如果服务器不健康,它将不会接收请求。更多详情可以参考这个issue

    【讨论】:

      猜你喜欢
      • 2018-04-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多