A load balancer receives connections and distributes them across several back-end systems. It can consider availability, current load, response time or a fixed algorithm. If one server fails a health check, new traffic can be sent to healthy instances.
Load balancing improves resilience but is not automatically high availability. The balancer itself, shared databases, sessions and dependencies can remain single points of failure. Security rules and TLS handling must also be consistent across the path.
Which security details matter?
- - Restrict access to the origin so it cannot bypass the public controls.
- - Define which forwarded headers are trusted and overwrite client values.
- - Protect health and administration endpoints.
- - Test failure behavior, session handling and capacity under realistic load.
Layer 4 or Layer 7?
Layer-4 balancing works mainly with connections and addresses. Layer-7 balancing understands protocols such as HTTP and can route by host or path, apply detailed rules and terminate TLS. The right choice depends on required visibility and complexity.
Which distribution methods exist?
| Method | Property | Useful when |
|---|---|---|
| Round robin | Assigns new requests in sequence. | Backends have similar capacity and requests are comparable. |
| Least connections | Prefers the backend with the fewest active connections. | Connections have substantially different lifetimes. |
| Weighting | More capable instances receive a larger share. | Backend capacity or versions differ. |
| Hashing | Repeatedly maps one attribute to the same backend. | Controlled affinity is needed; failure and scaling still require planning. |
What happens to sessions and TLS?
Stateless applications or a shared session store make failover easier. Sticky sessions bind a user to one instance and can create uneven load or session loss when it fails. If the balancer terminates TLS, traffic to the backend still requires appropriate protection and an unambiguous indication of the original connection.
Planning health checks and failover
A health check should represent the function that matters to users without running an expensive end-to-end test every second. Superficial checks retain broken instances; overly sensitive checks may remove every backend during one dependency failure. Failover, recovery and capacity with a failed zone therefore belong in regular operational and load tests.
Thank you for your feedback! We will review it and optimize this content.