如何确保新的自动缩放的Azure App Service实例在处理流量之前是热的? [英] How can I make sure a new autoscaled Azure App Service instance is warm before it handles traffic?

查看:96
本文介绍了如何确保新的自动缩放的Azure App Service实例在处理流量之前是热的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在应用程序服务上启用自动缩放后,Azure将根据设置规则根据需要添加实例.我总是从至少2个实例开始.我想确保在应用程序代码完全初始化之前,不会将流量定向到新的应用程序服务实例.我怎样才能做到这一点?是否可以添加超时?还是以某种方式自动完成?

解决方案

我该怎么做?是否可以添加超时?还是以某种方式自动完成?

如果您使用水平缩放(也称为横向扩展和横向扩展),则在配置新资源时,azure将使您的应用程序继续运行而不会中断.

Azure将自动预热新实例的应用程序并添加负载平衡以自动在它们之间分配请求.您不需要自己单独配置负载平衡.

有关天蓝色自动缩放的工作原理的更多详细信息,您可以参考以下文章.


"Azure将自动预热新实例的应用程序"-您提供的链接没有说明-您可以提供其他参考吗?我基本上不希望将该实例添加到负载均衡器中,直到可以通过200 OK访问特定URL或在2分钟的硬超时后.

在Web应用扩展到2个实例后,如果将新请求发送到默认实例网站,则azure将预热新实例的Web应用.

您可以编写如下测试:

在web.config的webserver标记中添加以下配置代码以跟踪所有请求:

<tracing>  
  <traceFailedRequests>  
    <clear/>  
    <add path="*">  
      <traceAreas>  
      <add provider="WWW Server" areas="Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module,Rewrite,iisnode" verbosity="Verbose" />  
      </traceAreas>  
      <failureDefinitions statusCodes="200-600" />  
    </add>  
  </traceFailedRequests>  
</tracing> 

然后,如果您的网站在访问网络应用程序后扩展到2个实例.负载平衡不会将请求重定向到第二个实例,因为该实例的进程不会启动. Azure将自动预热第二个实例的Web应用.

您可以找到如下图所示的日志:

日志结果:

fr00030.xml(您可能发现该进程是5860个旧实例):

fr00031.xml(您可能发现该过程是8164个新实例,耗时4015毫秒)

此外,正如拜伦·塔迪夫(Byron Tardif)所说,如果要启用自定义预热(预热所有页面),则可以使用 解决方案

How can I do this? IS it possible to add a timeout? Or is it done automatically somehow?

If you use horizontal scaling, also called scaling out and in, azure will keep your application continues running without interruption as new resources are provisioned.

Azure will automatically warm up the new instance's application and add a Load Balance to distribute the requests between them automatically. You don't need to configure the load balance separately by yourself.

More details about how azure auto scale work, you could refer to this article and this article.


"Azure will automatically warm up the new instance's application" - the links you provided do not say this - can you provide other references? I essentially don't want the instance added to a load balancer until a specific URL is accessible with 200 OK or after a hard timeout of 2 minutes.

After the web app scale out to the 2 instance, if the new request are send to the default instance web site , azure will warm up the new instance's web app.

You could write a test as below:

Add below config codes in web.config's webserver tag to trace all the request:

<tracing>  
  <traceFailedRequests>  
    <clear/>  
    <add path="*">  
      <traceAreas>  
      <add provider="WWW Server" areas="Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module,Rewrite,iisnode" verbosity="Verbose" />  
      </traceAreas>  
      <failureDefinitions statusCodes="200-600" />  
    </add>  
  </traceFailedRequests>  
</tracing> 

Then if your site scale out to 2 instance, after you access the web app. Load balance will not redirect the request to the second instance since the instance's process doesn't start. Azure will auto warm up the second instance's web app.

You could find the log as below image shows:

The log result:

fr00030.xml(you could find the process is 5860 old instance):

fr00031.xml(you could find the process is 8164 new instance and takes 4015 msec)

Besides, as Byron Tardif says, if you want to enable custom warm up(warm up all the pages), you could use Application Initialization Module.

It will also be called before the new request access your second web app instance.

这篇关于如何确保新的自动缩放的Azure App Service实例在处理流量之前是热的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆