我有一个在2个实例上运行的Azure应用服务。我尝试了高级应用程序重新启动,并设置了90秒或更长时间的重新启动延迟。
其中一个实例重新启动时,客户端请求似乎仍被发送到重新启动的实例。我发现请求需要60秒钟以上才能返回。
我会认为,当其中一个实例重新启动时,在准备好处理请求之前它将不可用。
如果我需要重新启动其中一个实例,该如何确保没有中断任何人?
ASP.Net 4.6.1
答案 0 :(得分: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 Apps安装了
应用程序初始化模块。您可以从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/
答案 1 :(得分:0)
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。