Load balancing in Azure

As an application developer or DevOps, we always have the question of how to load balance applications or infrastructure like WebApps, Cloud Services or Virtual Machines in Azure.

Currently, Azure provides three different managed load balancing solutions. Each solution can be broadly classified into one of two categories:

  1. DNS based load-balancing : This solution can load balance the traffic to different cloud services and webapps located in different data centers, in-fact to other external hosted endpoints. The DNS based load balancing is achieved through Azure Traffic Manager.
  2. Network based load-balancing: The network based load balancing solution can load balance the incoming Internet traffic to different virtual machines of a cloud service, or load balance the traffic between virtual machines in a virtual network. The network based load balancing is achieved using Azure Load Balancer and Azure Application Gateway.

Let’s briefly discuss these load balancers:

Azure Traffic Manager: Azure Traffic Manager primarily helps to route the traffic to the different cloud service, web apps or external endpoints based on intelligent policies applied to DNS queries for the domain names of the resources. The figure below illustrates how Azure Traffic Manager helps in load-balancing the traffic:

TrafficManager01

The basic process is as follows:

  1. An Internet client queries a domain name corresponding to a web service.
  2. DNS forwards the name query request to Traffic Manager.
  3. Traffic Manager chooses the next cloud service in the Round Robin list and sends back the DNS name.
  4. The Internet client’s DNS server resolves the name to an IP address and sends it to the Internet client.
  5. The Internet client connects with the cloud service chosen by Traffic Manager.

Traffic manager could be configured with the following policies:

  1. Failover : The failover policy could be used when you want to use a primary endpoint for all traffic, but provide a secondary endpoint in case the primary becomes unavailable.
  2. Performance (latency): If you have endpoints in different geographic locations and you want clients to use the “closest” endpoint in terms of the lowest latency, then performance policy would be suitable candidate for the policy rule.
  3. Round robin: The round robin policy would be applied when you want to distribute the load across a set of cloud services in the same datacentre or different datacentres.

It’s is very interesting to note that actually no traffic flows through Azure Traffic Manager, instead the client directly connects to the identified endpoint. The Traffic Manager only acts as an intelligent DNS. Additionally, your clients would always be impacted by the DNS Time-To-Live (TTL) caching during endpoint switch-over.

Azure Load Balancer: Azure Load Balancer is a transport Level (TCP/UDP) based Azure managed layer 4 load balancing solution which could be used for load balancing the traffic between cloud services or virtual machines in the same region or Virtual Network.

Currently, Azure Load Balancer only supports distribution though round-robin policy and distributes a specific type of incoming traffic across multiple virtual machines or cloud services in a load-balanced set. One of the very common use cases of Azure Load Balancer is to load-balance between servers in different tiers in a multi-tier application ( for example web, api and database tiers).

The diagram below outlines a basic load balancer scenario

AzureLoadBalancer01

Azure Application Gateway: Azure Application Gateway is a layer -7 based Azure managed HTTP load balancing solution. The Application Gateway uses Azure Load Balancer at the transport level and then applies the routing rules to support layer-7 ( HTTP) load balancing.

Application Gateway currently supports the following:

  1. HTTP load- balancing
  2. SSL termination
  3. Cookie based session affinity

The primary use cases for Application Gateway are :

  1. If your application requires session affinity i.e the clients want to reach same backend virtual machine.
  2. If your web servers do not want to handle the SSL overhead and you require the manage the SSL termination at the gateway.
  3. If your application requires multiple HTTP request on the same TCP connection to be load balance on the different backend virtual machines, the classic usage example is Content Delivery Network (CDN).

The table below helps to summarize the managed load balancing options available in Azure:

 

Azure managed load balancing options

Category

Type

Supported Azure Infrastructure

Region

Supported Policies

Azure Traffic Manager DNS None Azure WebApps, Cloud Service, external endpoints Cross Region Failover, Performance, Round-Robin
Azure Load Balancer Network (TCP/UDP) Layer 4 Azure Cloud Services and Azure Virtual Machines Within same Virtual Network None
Application Gateway Network (TCP/UDP) Layer 7 Azure Virtual Machines Within same Virtual Network None

So depending upon your application’s requirement, you have an option of choosing either DNS based load balancer through Azure Traffic Manager or Network based load balancer through Azure Load Balancer and Azure Application Gateway.

Leave a Reply