Comparison
Load balancervsService discovery
Load balancer
one address takes all the traffic and spreads it across the instances, skipping the ones failing their health check.
A component distributing requests across backends and removing unhealthy ones from rotation. Layer 4 balances connections and is fast and protocol-agnostic; layer 7 understands HTTP and can route, retry and rewrite. Its algorithm matters under uneven request costs: round robin sends work to a saturated instance, least-connections does not.
Full entry →Service discovery
instances come and go constantly and callers never hold a stale address, because nobody is configured with one.
The mechanism by which a caller finds a currently-healthy instance of something whose addresses change all the time. On a container platform it is usually DNS plus a continuously-updated endpoint list maintained by the control plane, rather than anything the application does. The reason it is infrastructure rather than code is that the set of instances changes on every deploy, every scale event and every node replacement.
Full entry →