Azure Traffic Manager Documentation

Feedback

Azure Traffic Manager

Azure Traffic Manager is a DNS-based traffic load balancer that enables you to distribute traffic optimally to services hosted in Azure or even externally. Traffic Manager allows you to control the distribution of traffic to your service endpoints by using the DNS. You can choose different ways to route traffic, such as prioritizing certain endpoints, sending traffic to the lowest latency endpoints, or using geographic-based routing.

Note: Traffic Manager works at the DNS level. It doesn't inspect the actual traffic flowing to your endpoints.

Key Features

  • High Availability: Route traffic to healthy endpoints, automatically failing over to a secondary endpoint if the primary is unavailable.
  • Performance Optimization: Direct users to the closest or fastest available endpoint based on latency.
  • Hybrid Cloud Scenarios: Extend Traffic Manager to include on-premises endpoints for hybrid cloud solutions.
  • Traffic Distribution Methods: Support for various routing methods including Priority, Weighted, Performance, Geographic, Multivalue, and Subnet.
  • Endpoint Monitoring: Configurable health checks for endpoints to ensure traffic is only sent to healthy services.

Introduction to Traffic Manager

This section provides a foundational understanding of Azure Traffic Manager, its purpose, and how it helps in building resilient and performant cloud applications. We'll cover the core principles of DNS-based traffic routing and its advantages over traditional load balancing methods.

Key Concepts

  • Traffic Manager Profile: The core configuration entity that defines your traffic routing rules, endpoint definitions, and health check settings.
  • Endpoint: A service that Traffic Manager can route traffic to. Endpoints can be Azure services (e.g., App Services, VMs, Public IP addresses) or external services.
  • DNS Query: The process by which a client's device resolves a domain name to an IP address. Traffic Manager intercepts these queries.
  • Health Probe: A mechanism to periodically check the health of your endpoints.

Traffic-Routing Methods

Traffic Manager supports several intelligent routing methods to cater to diverse application needs:

Priority Routing

This method directs all traffic to a primary endpoint. If the primary endpoint is unavailable, traffic is automatically rerouted to the next available endpoint in the priority order. This is ideal for failover scenarios.

// Example scenario for Priority Routing
// Endpoint 1 (Primary) - Region: East US
// Endpoint 2 (Secondary) - Region: West US
// If East US is unhealthy, traffic goes to West US.

Weighted Routing

Assign a weight to each endpoint. Traffic Manager distributes traffic proportionally to the assigned weights. This allows you to perform canary releases or gradual rollouts.

// Example scenario for Weighted Routing
// Endpoint A - Weight: 70%
// Endpoint B - Weight: 30%
// 70% of traffic goes to Endpoint A, 30% to Endpoint B.

Performance Routing

Routes traffic to the endpoint with the lowest network latency from the client. This is excellent for improving user experience by connecting them to the closest available resource.

// Example scenario for Performance Routing
// User in Europe -> Endpoint in Europe (lowest latency)
// User in Asia -> Endpoint in Asia (lowest latency)

Geographic Routing

Directs traffic to specific endpoints based on the geographic location of the user. Useful for compliance or tailoring content by region.

// Example scenario for Geographic Routing
// Users from North America -> Endpoint in North America
// Users from Europe -> Endpoint in Europe

Multivalue Routing

Returns multiple healthy endpoint IP addresses in a single DNS response. The client then randomly picks an endpoint from the list. Useful for basic load balancing and high availability.

Subnet Routing

Allows you to map specific IP address ranges to specific endpoints. This is useful for providing specific network experiences to defined user groups.

Creating and Managing Traffic Manager Profiles

You can create and manage Traffic Manager profiles using the Azure portal, Azure PowerShell, Azure CLI, or ARM templates.

Using the Azure Portal

  1. Navigate to the Azure portal.
  2. Search for "Traffic Manager profiles" and select it.
  3. Click "Create" to start the profile creation wizard.
  4. Configure the profile name, resource group, region, and most importantly, the DNS traffic-routing method.
  5. Add your endpoints, specifying their type, name, and target resource or IP address.
  6. Configure health probe settings, including protocol, port, and intervals.
  7. Review and create the profile.

Using Azure CLI

az traffic-manager profile create \
  --name "MyTrafficManagerProfile" \
  --resource-group "MyResourceGroup" \
  --output-type "nested" \
  --routing-method "Performance"

az traffic-manager endpoint create \
  --name "MyEndpoint1" \
  --profile-name "MyTrafficManagerProfile" \
  --resource-group "MyResourceGroup" \
  --type "azureEndpoints" \
  --target-resource-id "/subscriptions/.../resourceGroups/MyResourceGroup/providers/Microsoft.Web/sites/MyApp1" \
  --priority 1 \
  --weight 100 \
  --priority-item-type "Microsoft.Web/sites"
                

Monitoring and Troubleshooting

Effective monitoring is crucial for maintaining the health and performance of your services managed by Traffic Manager.

Azure Monitor Integration

Traffic Manager integrates with Azure Monitor to provide metrics on query counts, latency, and endpoint health status. You can set up alerts based on these metrics.

Common Troubleshooting Steps

  • Check Endpoint Status: Ensure all configured endpoints are healthy and accessible.
  • Verify DNS Configuration: Confirm that your custom domain is correctly CNAME'd to the Traffic Manager profile's DNS name.
  • Review Health Probe Settings: Make sure the health probe protocol, port, and path are correctly configured for your endpoints.
  • Analyze DNS Resolution: Use tools like nslookup or dig to check how DNS queries are being resolved.
  • Test Different Routing Methods: Experiment with different routing methods to understand how traffic is directed under various conditions.

Best Practices

  • Use Multiple Regions: Deploy your application in multiple Azure regions for disaster recovery and improved availability.
  • Configure Health Probes Correctly: Set up probes that accurately reflect the health of your application, not just the underlying server.
  • Test Failover: Regularly test your failover mechanisms to ensure they work as expected.
  • Monitor Performance: Keep an eye on endpoint latency and availability metrics.
  • Understand TTL: Be aware of the Time-To-Live (TTL) for DNS records, as it affects how quickly clients receive updates after changes.
  • Combine Routing Methods: For complex scenarios, consider combining methods like Priority with Performance.