Azure Load Balancer

Azure Load Balancer is a high-performance, highly available network load balancer that distributes inbound or outbound traffic across your virtual machines and containers. It operates at Layer 4 (TCP/UDP) of the OSI model and provides services such as:

High Availability

Ensures your applications remain accessible even if some instances fail.

Scalability

Handles fluctuations in traffic by distributing the load across available resources.

Health Probes

Monitors the health of backend instances and routes traffic only to healthy ones.

Standard SKU Features

Includes advanced features like outbound connectivity, VNet integration, and availability zones.

How Azure Load Balancer Works

Azure Load Balancer uses a hash-based distribution algorithm to distribute traffic. When traffic arrives at the load balancer, it is directed to one of the backend instances based on a specific set of rules. Health probes are configured to continuously check the status of backend instances. If an instance becomes unhealthy, the load balancer automatically stops sending traffic to it until it recovers.

Key Components

  • Frontend IP configuration: Public or private IP addresses that clients connect to.
  • Backend address pool: Contains the virtual machines or scale set instances that will receive the traffic.
  • Load balancing rules: Define how traffic is distributed to the backend pool, including protocol, ports, and session persistence.
  • Health probes: Used to determine the health of backend instances.
  • Inbound NAT rules: Map a public IP address and port combination to a specific backend instance and port.
  • Outbound rules (Standard SKU): Control outbound connectivity for backend instances.

Use Cases

Azure Load Balancer is ideal for a variety of scenarios, including:

  • Distributing traffic to web servers or application servers.
  • Ensuring high availability for stateful applications.
  • Providing scalable access to containerized workloads.
  • Enabling outbound internet connectivity for virtual machines.

Getting Started

To get started with Azure Load Balancer, you can use the Azure portal, Azure CLI, or PowerShell. Here's a simple example using Azure CLI to create a basic load balancer:


az network lb create \
    --resource-group MyResourceGroup \
    --name MyLoadBalancer \
    --sku Standard \
    --frontend-ip-name MyFrontend \
    --public-ip-address MyPublicIP

az network lb rule create \
    --resource-group MyResourceGroup \
    --lb-name MyLoadBalancer \
    --name MyHttpRule \
    --protocol Tcp \
    --frontend-port 80 \
    --backend-port 80 \
    --frontend-ip-name MyFrontend \
    --backend-pool-name MyBackendPool \
    --idle-timeout 15 \
    --enable-tcp-reset true
                

Further Reading