🔌 gRPC Intermediate

How does gRPC handle load balancing?

Answer

gRPC supports load balancing at two levels: (1) Proxy load balancing — a proxy (Envoy, NGINX, Traefik) terminates gRPC connections from clients and distributes them to backend servers. The client doesn't know about individual backends. This is the simplest approach and works well with Kubernetes + Envoy/Istio service mesh; (2) Client-side load balancing — the gRPC client resolves multiple server addresses (via DNS or service discovery) and distributes calls directly. Policies include round-robin (default) and pick-first. Client-side LB eliminates the proxy hop for lower latency. gRPC integrates with DNS-based discovery and xDS (the API used by Envoy) for dynamic configuration. In Kubernetes, since ClusterIP round-robins at the TCP level (not request level), gRPC's long-lived HTTP/2 connections all go to one pod — client-side LB or a service mesh is required for proper per-request load balancing.