Azure webapi 预热

Azure webapi warmup

阅读文档时:https://docs.microsoft.com/en-us/azure/app-service/deploy-staging-slots#swap-operation-steps,第4步,指定:

If auto swap is enabled with custom warm-up, trigger Application Initiation by making an HTTP request to the application root ("/") on each instance of the source slot.

If applicationInitialization isn't specified, trigger an HTTP request to the application root of the source slot on each instance.

If an instance returns any HTTP response, it's considered to be warmed up.

这是否意味着 1) 必须为交换启用自定义预热才能调用 root(或任何其他 url),或者 2) 如果自定义预热未启用它调用 root?无论 1) 还是 2):如果没有指定,返回的所有状态代码都会告诉交换进程插槽已预热?

更新 我阅读文档的方式 (https://docs.microsoft.com/en-us/azure/app-service/deploy-staging-slots#swap-operation-steps):

... App Service does the following to ensure that the target slot doesn't experience downtime:

1. ...
2. ...
3. ...
4. If auto swap is enabled with custom warm-up, **[AppService will]** trigger Application Initiation by making an HTTP request to the application root ("/") on each instance of the source slot.

If applicationInitialization isn't specified, **[AppService will]** trigger an HTTP request to the application root of the source slot on each instance.

If an instance returns any HTTP response, it's considered to be warmed up.
5. ...

可是我好像看错了?

让我一一回答你的问题:

1: custom warm-up has to be enabled for the swap to call root (or any other urls)

Yes, if auto-swap is enabled and you want the staging slot to warm up before the swap process starts. Otherwise, it will warm up on the first request and delay the response until the warm up is complete.


2: or, if custom warm-up isn't enabled it calls root?

It will not call root by itse lf it not specified under system.webServer > ApplicationInitialization in web.config file.


3: Regardless of 1 or 2: if nothing is specified, all status codes returned tells the swap process that the slot is warmed up?

It will just swap the slots if nothing is specified, without considering the warm-up at all. Only when the applicationInitialization block is available in web.config file then it will wait for ApplicationInitialization module to return a completion status, and then proceed with the swap.


即使在暂存槽完成预热后,考虑到启动时的配置差异,交换暂存槽工作进程可能仍会重新启动。

我观察到当暂存和生产配置完全匹配时,交换过程导致零停机。

swap过程中应用预热重启还有其他几种情况,请参考这篇文章: https://ruslany.net/2017/11/most-common-deployment-slot-swap-failures-and-how-to-fix-them/