question

PonsBertrand-6832 avatar image
0 Votes"
PonsBertrand-6832 asked ·

Azure App Service - ARR Affinity - Auto-scaling - Stateful application

I would like to get details on the behavior of the app with ARR Affinity enabled and autoscaling.

Let's say I deploy a stateful ASP.NET web app on Azure Web App. Therefore I enable ARR Affinity. I configure autoscaling as well.

What happens if ever an instance is put down due to autoscaling. Does ARR Affinity prevent the scale in as long as user session is still active, or is the user session suddenly broken?

Could you please then give pieces of advice on how to configure stateful application in Azure Web App (or something else)?

Thank you!

azure-webappsazure-webapps-scaling
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

ajkuma-MSFT avatar image
1 Vote"
ajkuma-MSFT answered ·

@PonsBertrand-6832 , Welcome to Microsoft Q&A! Thanks for posting a good question.


Azure WebApps by default have ARR Affinity cookie enabled, this cookie pairs a client request to a specific server. However, Azure Web Apps is a stateless platform and, in an environment, where we are scaling the Website across multiple instances, the ARR Affinity cookie will be bound to a specific server. In case, the server is no longer in rotation, then all the requests corresponding to the ARR Affinity cookie will fail. It’s advisable to avoid the use ARR cookies in a scaled environment where we have multiple instances that serve our application requests. Disabling ARR cookies is a sustainable resolution for issues related to ARR Affinity cookies in scaled environments, where these cookies rely on the relationship with the worker machine they are paired with.


Also, when we have ARR Affinity cookies enabled, we are truly not utilizing the scaling ability where a requests can get handled by any instance that has the resources to handle the request. Instead, based on ARR Affinity cookie mapping, the requests will always go to only to the server tied to the Affinity cookie.


If your application is stateful, scaling up would be best, while if your application is stateless, scaling out gives you more flexibility and higher scale potential.


For more information about “stateful” vs “stateless” applications kindly watch the following video:
Planning a Scalable End-to-End Multi-Tier Application on Azure App Service.


Improve scalability in an Azure web application





· 1 ·
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

To benefit the community, instead of edit on the answer above ( added it as a comment):
Just to add additional clarity on the statement (above) -" Azure Web Apps is a stateless platform and, in an environment, where we are scaling the Website across multiple instances, the ARR Affinity cookie will be bound to a specific server. In case, the server is no longer in rotation, then all the requests corresponding to the ARR Affinity cookie will fail" - meaning they wouldn't be able to access any in process information for that particular user on a different instance.

1 Vote 1 ·