When should you use Azure Traffic Manager vs Azure Load Balancer?
High availability is very important nowadays, as a downtime of just a couple of minutes can cause a loss of thousands or even millions of dollars. Because of this, it is vital to plan the architecture of infrastructure from the beginning of the deployment. The highest percentage and, almost impossible to achieve, is referred to as ‘five 9s’ (99.999 percent) availability”. There are different Azure technologies that can be used to reach high availability depending on the company’s needs.
Every web application has its own requirements. That is why designing high-availability for web-apps is not easy. Many components can fail, causing downtime to the system. Using Azure, you can create robust systems that use high availability combining different technologies.
In this blog post, we will look at Azure Load Balancer and Azure Traffic Manager.
How does Azure Load Balancer works?
Azure Load Balancer allows you to distribute the traffic across a group of backend resources or servers using Load Balancing Rules. Taking a simple example, imagine VNEXT IQ is using a Highly Available environment with three webservers hosting the webpage. Azure Load Balancer public IP is pointing to the domain “vnextiq.com”. When you browse to http://vnextiq.com/, the load balancer will receive the incoming traffic requesting the website. Depending on which load balancing rule is configured in the load balancer, the respective criteria will be used to balance the traffic between those three web servers. Here is a diagram depicting how Public Load Balancer works:
The load-balancing rule defines how traffic is distributed to the VMs. Azure Load Balancer uses a different distribution algorithm depending on the Source IP, Source Port, Destination IP, Destination Port, and Protocol Type. The hash is a piece of computed information that is not easy to get reverse engineered.
The Internal Load Balancer traffic is not exposed to the public internet, but only to resources that are inside a virtual network or that use a VPN to access Azure infrastructure. An internal Load Balancer enables the following types of load balancing:
- Within a virtual network
- For a cross-premises virtual network
- For multi-tier applications
- For line-of-business applications
There are resources in Azure that as part of the internal architecture of the resource uses Load Balancer by default. As a user, you will not need to deploy or configure a load balancer if you deploy an Azure App Service (PAAS environment). The technology that Azure App Service uses to balance the traffic when a scale-out is performed is an Azure Load balancer. Additionally, when an Azure Virtual Machine Scale Set (IAAS environment) is deployed you can select if you want that a Load Balancer balance the traffic between different instances of virtual machines.
For IAAS Virtual Machine Scale, Azure Load Balancer comes in two flavors: Basic and Standard. Both have some differences in terms of functionality.
Azure Traffic Manager
The Azure Traffic Manager is a cloud-based load balancing service that allows you to control the distribution of user traffic for service endpoints in different datacenters. Traffic Manager is not a proxy or a gateway. Traffic Manager does not see the traffic passing between the client and the service; it uses DNS to direct traffic to the appropriate backend pool. Azure Traffic Manager operates at the DNS level as there is no concept of “IP Address” for Traffic Manager. In other words, the Traffic Manager is not aware of the IP address of the endpoint because it works with DNS CNAME records.
The main feature of Azure Traffic Manager is that it allows increased application performance, allowing you to run cloud services or websites in data centers located around the world. Traffic Manager improves application responsiveness by directing traffic to the endpoint with the lowest network latency for the client.
Azure Traffic Manager routing methods:
- Performance: It routes the traffic to the fastest responsive node.
- Priority: It routes the traffic to a specific node if the node goes down.
- Weighted: It routes the traffic based on the weight assigned to each node.
- Geographic: It routes the traffic to specific nodes based on the source location.
- Subnet: It routes the traffic to a specific node based on an IP address range.
- Multivalue: It routes the traffic to a specific number of nodes. It will return multiple IPv4 or IPv6 endpoints.
There are scenarios that require more sophisticated traffic routing than the routing provided by a single Traffic Manager profile. You can nest Traffic Manager profiles to combine benefits of more than one traffic-routing method. Nested profiles allow you to override the default Traffic Manager behavior to support larger and more complex application deployments. Also, it enables you to improve the availability of your critical applications by monitoring your hosted Azure service endpoints and providing automatic failover capabilities when a service goes down.
One of the most important aspects to consider when configuring your Traffic Manager profile is TTL, known as the time-to-live (TTL) for a DNS record. In the context of Traffic Manager, this value represents the time that passes between endpoint health checks. The shorter the TTL, the higher the frequency of checkups and the more effective Traffic Manager will be at routing traffic away from unresponsive endpoints. You can set, at a per profile level, the DNS TTL to be as low as 0 seconds and as high as 2,147,483,647 seconds.
- A higher TTL reduces the number of queries that land on the Traffic Manager DNS servers, which can reduce the cost for a customer since the number of queries served is a billable usage.
- A higher TTL can potentially reduce the time it takes to do a DNS lookup.
- A higher TTL also means that your data does not reflect the latest health information that Traffic Manager has obtained through its probing agents.
To sum it up, we learned that the Azure Traffic Manager has been designed to distribute traffic globally (Multiregional environments). Nevertheless, the Azure Load Balancer can only route traffic inside an Azure region, as it only works with Virtual Machines in the same region. You can also set up Traffic Manager to work with Azure App Service, routing the user to the closest App Service instance, improving the performance of the WebApp. This is very important to know when you are designing architecture on Azure. You can combine these services to create a complex cloud or hybrid architectures to provide high availability and maximize performance.