3

ARR Affinity in Azure App Service

 1 year ago
source link: https://joonasw.net/view/arr-affinity-in-azure-app-service
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

ARR Affinity in Azure App Service

Posted on: 24-06-2016 1 Comment



Some of you who develop on Azure's App Service platform may have noticed this new switch in Application Settings:

ARR Affinity

So what is ARR Affinity and why does it improve performance?

If ARR Affinity is enabled, the IIS server acting as the load balancer will place a cookie on responses that causes a user to always hit the same instance within their session. This is good for legacy application compatibility as they may not have been designed with load balancing in mind.

But if your app has been designed for load balancing (i.e. your app is stateless, session state stored elsewhere), you should disable this.

So how can it improve performance? By disabling ARR Affinity, the load balancer is free to distribute the traffic as it wants. This means each instance's individual workload is much more even.

It's nice we finally got a switch for this as previously you would either have to open Resource Explorer and edit the app (note the clientAffinityEnabled flag):

Resource Explorer ARR Affinity switch

The other option would be to set a response header "Arr-Disable-Session-Affinity: true". Like this:

<system.webServer>
  <httpProtocol>
    <customHeaders>
      <add name="Arr-Disable-Session-Affinity" value="true" />
    </customHeaders>
  </httpProtocol>
</system.webServer>

While ARR Affinity helps with compatibility, it cannot be a final solution for an app. For one thing, you cannot enable Auto-scale as it would all come crashing down when one of the instances gets put down by auto-scale. And hardware failures happen, an instance might get killed because of that as well.

Bottom line: Enable ARR Affinity if your app stores state on the instance, otherwise disable it.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK