Redirecting Traffic Based On Priority Using Azure Traffic Manager

For any web application to work there has to be an associated end point, which means whenever users sends a request, endpoint is the first thing which gets hit. If I say in simple term, endpoint is an internet facing service which could be hosted either in Microsoft Azure or outside of Azure.
 

What is Azure Traffic Manager 

 
Now what is Traffic Manager? As it’s name suggests, it manages the traffic. It distributes the traffic across various Azure regions along with health monitoring capabilities. So, if you are planning for a multi-region support with high availability, it could be a perfect service for you.
 
Now, you must be thinking, what is the core which is making this happen? Actually it uses the DNS to route traffic to endpoints based on the selected traffic manger profile and the configured routing mechanisms. I’ll shortly mention about what all routing methods are available but before that let’s take a quick look at some of the major benefits which we can achieve using Traffic Manager.
 

Benefits of using Azure Traffic Manager

  • Traffic Manager provides automatic failover whenever endpoint goes down as it keeps monitoring the end points.
  •  In case of planned maintenance activity, Traffic Manager redirects the traffic to other end points which are configured. So, we need not to worry about any downtime windows.
  • Traffic Manager has the ability to perform calculation to know which end point will provide lowest latency to the user. In a way, Traffic Manager improves the responsiveness by redirecting the traffic to such end points.
  • Another important capability of Traffic Manager is, it not only supports Azure end points, but it also go hand-in-hand with external non-Azure endpoints.
  • And lastly, Traffic Manager allows to combine multiple routing methods to achieve any complex business scenarios using nested profiling mechanism.

Ways to manage traffic

 
Currently, there are 6 ways once can manage DNS routing.
 
Performance
 
This method is useful, when endpoints are configured in different geographic locations and one wants to select the closet one, in terms of lowest network latency.
 
Weighted
 
In this method, one can create endpoints with designated weights, ranging between 1 and 1000 and based on the weight, traffic is redirected accordingly.
 
Geographical
 
This method route users based on the geo location or say, it works based on the geography their DNS query originates from. It may look similar to performance but actually it’s different. The best use case, I can think of is, let’s say due to some compliance and government regulations one wants all the traffic from EAST US to be redirected to WEST US endpoint. So, this can be achieved by selecting the geo based profile.
 
Priority
 
As it’s name says, it works on the basis of assigned priority. So, whichever endpoint is having higher priority, traffic would be redirected to that one. By any chance, if endpoint having highest priority is down or not healthy, request will automatically be redirected to the endpoint which is assigned as 2nd highest priority and it keeps going on. Such routing method is very useful in disaster recovery scenarios.
 
Multivalue
 
In this type of routing method, there exists multiple endpoints for a single client request. One caveat here is, one can not go with server name mappings and has to mandatorily go with IPv4 or IPv6 one. Unfortunately, I couldn’t find any real-time use case here.
 
Subnet
 
This method allows to map range of IP addresses to specific endpoints. Say, you want certain users or to be specific certain IP addresses to always use WEST US endpoint and rest all can use other end points then this routing method can be used.
 
Well enough of theory. Let’s have a look at practical example of how priority based DNS routing works.
 

Priority based endpoint routing using Azure Traffic Manager

 
Let's start by opening the Azure portal using this and search for the Traffic Manager Profiles. Click on that and a new page will open as shown below,
 
Redirecting Traffic Based On Priority Using Azure Traffic Manager
 
Click on Create traffic manager profile and supply all the necessary parameters. Most of these parameters are self-explanatory, so I'm not going to dig deep into those. But make sure to select the Routing method as Priority.
 
Redirecting Traffic Based On Priority Using Azure Traffic Manager
 
Once you click on Create button, Traffic Manager profile will get created under the selected Resource Group as would be listed as shown below,
 
Redirecting Traffic Based On Priority Using Azure Traffic Manager
 
Now select the recently created profile and create teh endpoint as shown below,
 
Redirecting Traffic Based On Priority Using Azure Traffic Manager
 
As Target resource type, I've selected App Service as the web app I have created to load here is deployed as App Service.
 
NOTE
For this endpoint I've assigned the priority as 1 and my web app is hosted in West US.
 
Similarly we will create another endpoint with priority set as 2 and web app hosted in Central US region as shown below,
 
Redirecting Traffic Based On Priority Using Azure Traffic Manager
 
Now if you will go back to Traffic Manager profile, you will see both these endpoint listed over there as shown below,
 
Redirecting Traffic Based On Priority Using Azure Traffic Manager
 
Next comes is verification part. For that, let's try to run the application in a browser by hitting the URL mentioned for DNS name http://demochannel.trafficmanager.net. You will see that application is up and running with endpoint set as priority 1.
 
Redirecting Traffic Based On Priority Using Azure Traffic Manager
 
Let's go to App Services and and stop the one which is hosted in West US. Here we are trying to make priority 1 endpoint down and want to check if failover happens and priority 2 endpoint picks up.
 
Redirecting Traffic Based On Priority Using Azure Traffic Manager
 
As above screenshot says that we have stopped the app which was hosted in West US region. 
 
Now go and run the same URL again and you will notice that web application is still up and running and this time, it is running from Central US region, which was assigned priority 2. Here is the web app running from endpoint 2,
 
Redirecting Traffic Based On Priority Using Azure Traffic Manager
 
If you are interested in video tutorial of this article, you can refer to my channel
 
Hope you enjoyed learning this traffic redirection using priority based routing of Azure Traffic Manager.


Similar Articles