How Azure load balances scaled out App Service plan? How Azure load balances scaled out App Service plan? azure azure

How Azure load balances scaled out App Service plan?


The load balancer is created automatically and you can't see it.

Basically it sends the requests to instances at random, though it can be made "sticky" with ARR Affinity.You can find the setting in the App Service's Application Settings:

ARR Affinity toggle in Portal

If it is on, the load balancer will attach a cookie to responses if they don't already have it.It makes it so that future requests hit the same instance.Though of course if the instance is no longer there (because of auto-scale for example), then it will again go to a random instance.

The WEBSITE_INSTANCE_ID environment variable can tell you in the back-end which instance is handling the request.You can find a list of available variables here: https://github.com/projectkudu/kudu/wiki/Azure-runtime-environment