Skip to content

Load Balancer - External

🎯 Lab Objective

In this hands-on lab, you will learn how to:

  • Create and configure an Azure Public Load Balancer to distribute internet traffic
  • Set up backend pools and add virtual machines for load distribution
  • Configure health probes for automatic backend health monitoring
  • Create load balancing rules to control traffic flow
  • Test failover scenarios and validate high availability
  • Monitor load balancer performance using Azure Portal metrics

πŸ—οΈ Pre-Provisioned Environment

The following Azure resources have been pre-deployed in your environment:

Resource Overview

Resource TypeResource NameConfigurationPurpose
Resource Grouprg-loadbalancer-labContains all lab resourcesLogical container
Virtual Networkvnet-webtierSubnet for web serversNetwork foundation
Network Security Groupnsg-webserversHTTP/HTTPS traffic rulesSecurity layer
Web Server VMsvm-webserver-1/2/3IIS with unique contentBackend targets
Public IPpip-loadbalancerReserved for load balancerFrontend endpoint
Temp Public IPspip-webserver-*Individual VM accessTesting purposes

Network Architecture

Internet Traffic
↓
Azure Load Balancer (pip-loadbalancer)
↓
Backend Pool (vnet-webtier)
β”œβ”€β”€ vm-webserver-1 (IIS - Server 1)
β”œβ”€β”€ vm-webserver-2 (IIS - Server 2)
└── vm-webserver-3 (IIS - Server 3)

πŸš€ Lab Exercises

Part 1: Verify Pre-Provisioned Environment

Step 1: Navigate to Resource Group

  1. Open the Azure Portal
  2. Search for and select Resource groups
  3. Click on your lab resource group

Step 2: Verify Resources

Confirm the following resources are present:

ResourceTypeStatus
vm-webserver-1Virtual Machineβœ… Running
vm-webserver-2Virtual Machineβœ… Running
vm-webserver-3Virtual Machineβœ… Running
vnet-webtierVirtual Networkβœ… Available
nsg-webserversNetwork Security Groupβœ… Configured
pip-loadbalancerPublic IP Addressβœ… Reserved

Step 3: Test Individual Web Servers

  1. In your resource group, click on each pip-webserver-* public IP
  2. Copy the IP address from the overview page
  3. Open a new browser tab and navigate to each server:
    • http://[webserver-1-ip] β†’ Should show β€œWelcome from Server 1”
    • http://[webserver-2-ip] β†’ Should show β€œWelcome from Server 2”
    • http://[webserver-3-ip] β†’ Should show β€œWelcome from Server 3”

πŸ’‘ Note: Each server displays unique content to help you identify which server is responding during load balancing tests.


Part 2: Create the Public Load Balancer

Step 1: Start Load Balancer Creation

  1. In your resource group, click + Create
  2. Search for β€œLoad balancer”
  3. Select Load balancer by Microsoft
  4. Click Create

Step 2: Configure Basics

SettingValueNotes
SubscriptionYour subscriptionPre-selected
Resource groupYour lab resource groupPre-selected
Namelb-webserversDescriptive name
RegionSame as resource groupMust match VMs
SKUStandardRequired for advanced features
TypePublicInternet-facing
TierRegionalSingle region deployment

Step 3: Configure Frontend IP

  1. Click Next: Frontend IP configuration
  2. Click + Add a frontend IP configuration
SettingValueNotes
Namefrontend-webFrontend identifier
IP versionIPv4Standard internet protocol
IP typeIP addressUse existing public IP
Public IP addresspip-loadbalancerPre-created IP
Availability zoneZone-redundantHigh availability
  1. Click Add

Step 4: Skip Backend Pools (For Now)

  1. Click Next: Backend pools
  2. Click Next: Inbound rules (we’ll configure pools later)

Step 5: Deploy Load Balancer

  1. Click Next: Outbound rules
  2. Click Next: Tags (optional)
  3. Click Review + create
  4. Review the configuration
  5. Click Create

⏱️ Deployment Time: Typically takes 2-3 minutes to complete.


Part 3: Configure Backend Pool

Step 1: Navigate to Load Balancer

  1. Go to your resource group
  2. Click on lb-webservers
  3. Wait for deployment to complete if still in progress

Step 2: Create Backend Pool

  1. In the left menu, select Backend pools
  2. Click + Add

Step 3: Configure Backend Pool Settings

SettingValueNotes
Namebackend-webserversPool identifier
Virtual networkvnet-webtierTarget network
Backend Pool ConfigurationIP addressUse VM IP addresses
IP versionIPv4Match frontend

Step 4: Add Virtual Machines

  1. Under IP address and Virtual machine, click + Add
  2. For each web server VM:

VM 1:

  • Virtual machine β†’ Select vm-webserver-1
  • Network IP configuration β†’ Select the IP configuration
  • Click Add

VM 2:

  • Virtual machine β†’ Select vm-webserver-2
  • Network IP configuration β†’ Select the IP configuration
  • Click Add

VM 3:

  • Virtual machine β†’ Select vm-webserver-3
  • Network IP configuration β†’ Select the IP configuration
  • Click Add
  1. Click Save

πŸ” Verification: You should see all 3 VMs listed in the backend pool with their private IP addresses.


Part 4: Create Health Probe

Step 1: Navigate to Health Probes

  1. In your load balancer, click Health probes in the left menu
  2. Click + Add

Step 2: Configure Health Probe

SettingValuePurpose
Namehealth-probe-httpProbe identifier
ProtocolHTTPWeb service protocol
Port80Standard HTTP port
Path/Root page check
Interval15 secondsCheck frequency
Unhealthy threshold2 failuresFailover trigger

Step 3: Save Health Probe

  1. Click OK
  2. Wait for the probe to be created

πŸ’‘ How it Works: The health probe sends HTTP GET requests to each backend server every 15 seconds. If 2 consecutive requests fail, the server is marked unhealthy and removed from rotation.


Part 5: Create Load Balancing Rule

Step 1: Navigate to Load Balancing Rules

  1. In your load balancer, click Load balancing rules
  2. Click + Add

Step 2: Configure Load Balancing Rule

SettingValueNotes
Namerule-http-trafficRule identifier
IP VersionIPv4Match frontend
Frontend IP addressfrontend-webPreviously created
ProtocolTCPTransport protocol
Port80HTTP port
Backend port80Same as frontend
Backend poolbackend-webserversTarget pool
Health probehealth-probe-httpHealth monitoring

Step 3: Advanced Settings

SettingValuePurpose
Session persistenceNoneRound-robin distribution
Idle timeout4 minutesConnection timeout
TCP resetDisabledDefault setting
Floating IPDisabledStandard configuration

Step 4: Save Rule

  1. Click OK
  2. Wait for the rule to be created

Part 6: Test Load Balancer Functionality

Step 1: Get Load Balancer Public IP

  1. In your load balancer, click Overview
  2. Note the Public IP address under Frontend IP configuration
  3. Copy this IP address

Step 2: Basic Connectivity Test

  1. Open a new browser tab
  2. Navigate to http://[load-balancer-public-ip]
  3. Expected Result: You should see content from one of your web servers

Step 3: Load Distribution Test

  1. Refresh the page multiple times (F5 or Ctrl+R)
  2. Observe the responses: You should see different servers responding:
    • β€œWelcome from Server 1”
    • β€œWelcome from Server 2”
    • β€œWelcome from Server 3”
  3. Pattern: Requests are distributed across all healthy servers

Step 4: Command Line Testing (Optional)

If you have access to a command line with curl:

Terminal window
# Run this command multiple times to see load distribution
curl http://[load-balancer-public-ip]

🎯 Success Criteria: Traffic should be distributed across all 3 servers in a round-robin fashion.


Part 7: Test High Availability & Failover

Step 1: Simulate Server Failure

  1. Go to your resource group
  2. Click on vm-webserver-1
  3. Click Connect β†’ RDP (or use Bastion)
  4. Connect to the VM using provided credentials

Step 2: Stop IIS Service

  1. Once connected to vm-webserver-1:
  2. Open Server Manager
  3. Click Tools β†’ Internet Information Services (IIS) Manager
  4. In IIS Manager:
    • Expand the server name
    • Expand Sites
    • Right-click Default Web Site
    • Select Stop

Step 3: Monitor Health Status

  1. Return to Azure Portal
  2. Navigate to your load balancer
  3. Click Backend pools β†’ backend-webservers
  4. Observe: vm-webserver-1 should show as Unhealthy (may take 30-60 seconds)

Step 4: Test Failover

  1. Go back to your browser with the load balancer URL
  2. Refresh multiple times
  3. Expected Result: You should only see responses from Server 2 and Server 3
  4. Confirm: No traffic goes to the failed server

Step 5: Restore Service

  1. Return to the RDP session on vm-webserver-1
  2. In IIS Manager:
    • Right-click Default Web Site
    • Select Start
  3. Monitor: Server should return to Healthy status
  4. Test: Traffic should resume to all 3 servers

πŸ”§ Troubleshooting: If the server doesn’t show as unhealthy, verify the health probe settings and ensure the Default Web Site is actually stopped.


Part 8: Advanced Configuration & Monitoring

Step 1: Configure Session Persistence

  1. Navigate to Load balancing rules β†’ rule-http-traffic
  2. Click Edit
  3. Change Session persistence to Client IP
  4. Click Save
  5. Test: Now your browser should consistently hit the same server

Step 2: Adjust Health Probe Sensitivity

  1. Navigate to Health probes β†’ health-probe-http
  2. Click Edit
  3. Modify settings:
    • Interval: Change to 5 seconds
    • Unhealthy threshold: Change to 3 failures
  4. Click Save
  5. Observe: Faster detection of server issues

Step 3: View Performance Metrics

  1. In your load balancer, click Metrics
  2. Explore key metrics:
MetricPurpose
Data path availabilityOverall health percentage
Health probe statusBackend server health
Packet countTraffic volume
Byte countData transferred
VIP availabilityFrontend availability
  1. Create charts for different time ranges
  2. Set up alerts for critical metrics (optional)

πŸ”§ Troubleshooting Guide

Common Issues and Solutions

IssuePossible CauseSolution
Load balancer doesn’t respondIncorrect frontend IP configurationVerify public IP assignment
All traffic goes to one serverSession persistence enabledCheck load balancing rule settings
Health probe failsWeb service not runningVerify IIS is running on all VMs
Slow failoverHealth probe interval too longReduce probe interval and threshold
Backend pool emptyVMs not added correctlyRe-add VMs to backend pool

Health Probe Status Guide

StatusMeaningAction
HealthyServer responding correctlyNo action needed
UnhealthyServer failing health checksCheck web service status
UnknownInitial state or transitioningWait for probe results

πŸ§ͺ Additional Experiments

Try these optional exercises to deepen your understanding:

  1. Multiple Ports: Configure rules for HTTPS (port 443)
  2. Custom Health Checks: Create specific health check pages
  3. Load Testing: Use tools like Apache Bench to stress test
  4. Monitoring Alerts: Set up email alerts for health issues
  5. Network Security: Modify NSG rules and observe impact

πŸŽ“ Key Takeaways

After completing this lab, you should understand:

  • Azure Load Balancer distributes traffic across multiple backend servers
  • Health probes automatically detect and handle server failures
  • Backend pools group servers for load distribution
  • Session persistence affects how clients are routed to servers
  • Standard SKU provides advanced features and availability zones
  • High availability is achieved through automatic failover

πŸ“ˆ Load Balancer Concepts Summary

Distribution Methods

  • Round Robin: Default method, distributes evenly
  • Client IP Hash: Same client always goes to same server
  • Source IP Affinity: Based on source and destination IP

Health Monitoring

  • Probe Interval: How often to check server health
  • Unhealthy Threshold: Failed attempts before marking unhealthy
  • Probe Path: Specific URL to test (can be custom health page)

High Availability Features

  • Automatic Failover: Unhealthy servers removed from rotation
  • Zone Redundancy: Load balancer spans availability zones
  • Outbound Connectivity: SNAT for backend server internet access

πŸ“š Additional Resources