5.1.4.2. Configure Load Balancing Rules
5.1.4.2. Configure Load Balancing Rules
💡 First Principle: A load balancing rule is the fundamental traffic director for an Azure Load Balancer, precisely defining how inbound traffic on a specific frontend IP and port is distributed to backend resources.
Scenario: You have a web application behind an Azure Load Balancer. You need to create a rule to direct incoming HTTP traffic on port 80 to the backend web servers on port 80. Additionally, for a specific internal service, you need to ensure that all requests from a particular client IP always go to the same backend server.
What It Is: Load balancing rules are configurations that define how the Azure Load Balancer distributes incoming traffic to its backend pool.
Key components of a load balancing rule:
- Frontend IP address: The IP where clients connect.
- Protocol: TCP or UDP.
- Port: The frontend port exposed to clients.
- Backend port: The port on backend VMs.
- Backend pool: The group of VMs serving the requests.
- Health probe: Monitors backend health.
- Session persistence (affinity): Controls if a client’s requests always go to the same backend.
- Floating IP (Direct Server Return): Enables advanced scenarios like SQL AlwaysOn.
⚠️ Common Pitfall: Configuring a health probe that checks a port but not the application's actual health. The port might be open, but the application could be frozen. A good health probe checks an application-specific health endpoint (e.g., /healthz).
Key Trade-Offs:
- Stateless (No Affinity) vs. Stateful (Session Persistence): No affinity allows for even load distribution but doesn't work for apps that store session state locally. Session persistence ensures a client returns to the same server but can lead to uneven load distribution.
Reflection Question: How does configuring load balancing rules (specifying frontend/backend ports, protocols, health probes, and session persistence) fundamentally control how traffic is distributed, ensuring optimal load distribution, high availability, and session stickiness for stateful applications?