What Is a Load Balancer? Choosing Traffic Distribution and Health Checks
A load balancer distributes incoming requests or connections across multiple backend instances. It can spread traffic to improve throughput and resilience, but it does not automatically add servers or fix application state and capacity problems. Choose a distribution method for the request pattern and instance differences, and make health checks reflect whether an instance can accept new traffic.
A load balancer distributes incoming requests or connections across multiple backend instances. It can spread traffic to improve throughput and resilience, but it does not automatically add servers or fix application state and capacity problems. Choose a distribution method for the request pattern and instance differences, and make health checks reflect whether an instance can accept new traffic.
Where does a load balancer distribute requests?
A Layer 4 load balancer distributes TCP or UDP flows mainly using connection details such as IP addresses and ports. A Layer 7 load balancer can use higher-level information in HTTP requests, such as the host or path. NGINX documentation distinguishes HTTP/HTTPS balancing at L7 from TCP/UDP balancing at L4. Product terminology and capabilities vary, so check the supported layers and protocols for the service you use. (NGINX HTTP Load Balancing, NGINX TCP and UDP Load Balancing)
A typical flow is client → load balancer → backend instance. Instances generally serve the same application, and the load balancer sends new requests or connections according to its backend pool and health information. A reverse proxy that forwards traffic to multiple backends can also perform load-balancing work, but not every proxy provides distribution or health-check features.
Which distribution method should you choose?
First identify whether the unit being distributed is an HTTP request or a TCP/UDP connection. Then consider whether request duration is similar, connections remain open for a long time, and instance capacity is equal. An algorithm determines how traffic is assigned; it does not replace capacity planning.
| Method | Useful when | Trade-off |
|---|---|---|
| Round Robin | Instances have similar capacity and request costs are fairly even | When request durations vary, the amount of work in progress may still be uneven. |
| Least Connections | Connections last a long time or have different workloads | Connection count does not always represent CPU or memory work. |
| Weights | Instances have different capacity or processing ability | Load-test whether the weights represent the capacity difference well. |
| IP or key-based hash | Sending the same key to the same instance has a clear benefit, such as cache locality | Shared client IPs or skewed keys can create hotspots; mappings can also change when instances change. |
| Session affinity | The application still depends on instance-local sessions | Traffic can concentrate on an instance, and a failure can disrupt sessions. Consider shared session storage or stateless design where practical. |
Use the table as a starting point. NGINX uses Round Robin by default for HTTP balancing and also documents Least Connections, IP Hash, and Generic Hash. Available algorithms and behavior vary across NGINX Open Source, NGINX Plus, versions, and other products. For example, the current NGINX documentation says least_time is supported in NGINX Open Source starting with 1.31.0 and identifies some session-persistence features as Plus-only. Check the documentation for the version you deploy. (NGINX choosing a load-balancing method)
What should health checks test?
A health check, or probe, periodically helps a load balancer decide whether a backend can receive new traffic. Depending on the product, an unhealthy backend may be removed from the set of targets for new connections. A TCP probe generally checks whether a port accepts a connection; an HTTP or HTTPS probe can send a request to a specified path and inspect the response. Azure Load Balancer documents these probe types and their behavior within that product. (Azure Load Balancer health probes)
Match the probe protocol, port, path, response code, timeout, and failure threshold to the application's readiness to accept work. A check that only confirms the process is running can mark an instance healthy even when it cannot serve requests. Conversely, if the probe depends on every external dependency, one dependency outage could remove all backends from the pool. Define what state is ready for new requests, choose a dedicated endpoint and response rule, and verify it alongside the real request path. Aggressive thresholds can repeatedly remove and restore an instance during a short delay or startup.
Do not copy cloud-specific rules such as Azure probe IPs or port requirements to another product. Probe firewall rules, behavior when all backends are unhealthy, and whether existing connections continue depend on the provider and service. If health checks succeed while user requests fail, compare the application listener with the probe port and path, confirm the firewall allows the probe, and check whether the backend responds before the timeout. (Troubleshooting Azure Load Balancer health probe failures)
How do you configure an HTTP backend group in NGINX?
The following illustrative configuration defines two backends in the NGINX HTTP context and sends requests for / to the group. Replace the example backend names, ports, TLS, and network policy for your environment. This uses the default Round Robin method and belongs where an http block is valid in your NGINX configuration. (NGINX HTTP Load Balancing)
http {
upstream app_backend {
server app1.example.com;
server app2.example.com;
}
server {
listen 8080;
location / {
proxy_pass http://app_backend;
}
}
}This is a syntax example, not a configuration that was run or validated. In the installed NGINX environment, check the actual include-file structure and backend reachability, then apply the change gradually after a syntax check. Afterward, observe request counts, errors and latency per backend, health-check status, existing-connection handling, and traffic changes as instances leave or rejoin the pool. If traffic is uneven, examine client IP or session affinity, request cost, weights, connection duration, and each instance's actual capacity together.
What should you check before operating it?
Do backend instances run compatible application versions and configuration, with clear boundaries for shared data or sessions?
Have you confirmed whether you need L4 flow distribution or L7 request distribution, and checked supported protocols and product-specific features?
Have you validated the algorithm and weights against request cost, connection duration, and instance capacity?
Is session affinity necessary, and could it cause hotspots or session loss during an outage?
Do the health-check protocol, port, path, response, timeout, and threshold reflect readiness to receive new traffic?
Have you checked probe network rules and the product's behavior when all backends are unhealthy?
Have you prepared load and failure scenarios for adding or removing instances, restarts, and failed probes, along with a rollback plan?
Can you observe request volume, errors, latency, active connections, per-instance utilization, and probe status together?