Search code examples
azureazure-cloud-services

Disable affinity in Azure's Load Balancer for Cloud Services (Web/Worker roles)


I'm seeing a definite non-round-robin load-balancing pattern in Azure's load balancer for my cloud role. Most of the requests are going to the 1st instance of the two-instance of my Web-Api worker role setup.

How can I ensure that Azure's LB distributes requests equally?

Note the first screenshot from CloudMonix's dashboard contains CPU Utilization for 1st instance (60-65% sustained average) and 2nd screenshot contains CPU utilization for 2nd instance (2-5% sustained average) This is consistent across many different times I've looked into this.

Both of the instances are the same, only listen to many http requests and process them.

Instance 1 Instance 2


Solution

  • There actually is a way of configuring the loadBalancerDistribution for a Cloud Service in the .csdef file. The flaw is documentation updates :-(

    Please look at this article: https://azure.microsoft.com/en-us/blog/azure-load-balancer-new-distribution-mode/

    The value of LoadBalancerDistribution can be sourceIP for 2-tuple affinity, sourceIPProtocol for 3-tuple affinity or none (for no affinity. i.e. 5-tuple)

    I'll look in to getting the schema article updated to reflect this.

    As for the load distribution - if you have not specifically chosen the 2- or 3-tuple algorithm, you should be running with the 5-tuple.

    You can use https://resources.azure.com to look at the current configuration.

    I know that CPU is a reflection of load, but the load balancer balances based on network sessions, so please ensure that the CPU load and distribution of network sessions correlate. In your situation I would be surprised if they do not - just a reminder.

    Please look at this article to ensure you are not running with keep-alives: Extremely uneven cloud service load-balancing with Azure