Last week I wrote about load balancing workloads in Azure. That generated some other questions, such as “How do I ensure that my stakeholders connect to the closest instance in my web farm?”, “How do I ensure the best possible performance for my Web applications?”.
Microsoft Azure Traffic Manager allows you to control the distribution of traffic to your specified endpoints, which can include Azure cloud services, websites, and other endpoints. It works by applying a policy engine to Domain Name System (DNS) queries for the domain names of your Internet resources. Your Azure cloud services or websites can be running in different datacenters across the world and using the Traffic Manager helps you achieve the following:
- Improve availability of critical applications – Traffic Manager allows you to improve the availability of your critical applications by monitoring your endpoints in Azure and providing automatic failover when an Azure cloud service, Azure website, or other location goes down.
- Improve responsiveness for high performing applications – Azure allows you to run cloud services or websites in datacenters located around the world. Traffic Manager can improve the responsiveness of your applications and content delivery times by directing end-users to the endpoint with the lowest network latency from the client. (the closest to your users)
- Upgrade and perform service maintenance without downtime – Traffic Manager supports extended scenarios for hybrid cloud and on-premises deployments including the “burst-to-cloud,” “migrate-to-cloud,” and “failover-to-cloud” scenarios. For planned maintenance, you disable the endpoint in Traffic Manager and then wait for the endpoint to complete the servicing of existing connections. When there is no more traffic to the endpoint, you update the service on that endpoint and test it, then re-enable it in Traffic Manager. This helps you to maintain and upgrade your services without downtime for clients.
- Traffic distribution for large, complex deployments – With nested Traffic Manager profiles, in which a Traffic Manager profile can have another Traffic Manager profile as an endpoint, you can create configurations to optimize performance and distribution for larger, more complex deployments
As always, we have resources to help if you’re interested in scalability and performance in the cloud I recommend the following Microsoft Virtual Academy modules.
I built up on the environment we had in the last post by deploying 2 more front end websites that connect to our SQL back end. I deployed the in the “Central US” zone and configured a Load-Balanced Set in that location as well.
Today, we will configure the Traffic Manager to direct traffic to the closest instanced based on latency.
Step 1: Create a Traffic Manager Profile
- In the Azure portal, navigate to Traffic Manager
- Click Create a Traffic Manager Profile. or at the bottom of the portal click New, click Network Services, click Traffic Manager, then click Quick Createto begin configuring your profile.
- Configure the DNS prefix. Give your traffic manager profile a unique DNS prefix name. You can specify only the prefix for a Traffic Manager domain name. Select the appropriate subscription and select the load balancing method. Select the load balancing method. For more information about load balancing methods, see About Traffic Manager Load Balancing Methods. and Click “Create” to create your new profile.
- When the profile configuration has completed, you can find the newly created profile in the Traffic Manager pane in the Management Portal
Step 2: Add a Cloud Service or Website Endpoint to the Profile
In the portal in the Traffic Manager page , click the Endpoints tab to view the endpoints
At the bottom of the page, click Addto access the Add Service Endpoints dialogue box. It will lists the cloud services in your subscription under Service Endpoints. In our case we are running our App in VMs contained by Cloud Service. So we will select the cloud services in the list to enable them as endpoints for this profile. If we had Azure websites, we would click the Service Type dropdown, and then select Website.
After you select the endpoints for this profile, click the checkmark on the lower right to save your changes.
In the configure tab, you will find the DNS Name you gave your profile (in case you forgot what you entered)
To point your company domain name to a Traffic Manager domain name, modify the DNS resource record on your Internet DNS server to use the CNAME record type, which maps your company domain name to the domain name of your Traffic Manager profile. for example:
www.contoso.com IN CNAME canitprocampapp.trafficmanager.net
Step 3: Test the Profile
To test our profile I connected to all my VMs and edited the logo on each server to show a specific tag
1 and 2 are the 2 instances in the “East US” zone, Central 1 and 2 are in the “Central US” zone.
from Ottawa, Ontario I opened a browser and navigated to http://CanITProCampApp.trafficmanager.net and got the following result:
I asked one of my coworkers in Vancouver BC to do the same and he got the following result:
We can clearly see that our Traffic Profile is working as intended.
That’s it. We now have 2 load balanced set of web servers across different geography and a profile that will provide the closest to our clients.