Dave New
Dave New

Reputation: 40042

Azure Web App - Prevent routing to specific instances

We are hosting an ASP.NET Core application on an Azure App Service (Web Apps).

Our individual instances take some time to "preload" the required data needed to process requests. But when scaling out, requests will be routed to the instances still being prepared.

How does the App Service load balancer decide when an instance is ready and requests can be routed to it? Is there a way to prevent routing to some specific instance until we deem it ready?

Upvotes: 0

Views: 310

Answers (1)

Rob Reagan
Rob Reagan

Reputation: 7686

Try using the applicationInitialization node in your web.config. This instructs IIS to to issue warm-up requests to URLs that you designate before the application receives its first request.

I have used this on slow swaps before. But from reading the docs on IIS here, it looks like it'll also work for new instances. I haven't tried this when scaling out though - let me know if this works for you.

Here's example code of using it within the web.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <applicationInitialization>
      <add initializationPage="/pagetowarmup1.php" />
      <add initializationPage="/pagetowarmup2.php" />
      <add initializationPage="/pagetowarmup3.php" />
    </applicationInitialization>
  </system.webServer>
</configuration> 

Upvotes: 1

Related Questions