The gRPC throughput load balancer is a load balancer that implements the
grpc.Balancer interface
. It will open a
configured number of connections to a single address and not allow more than a
given number of concurrent requests per address.
In your code when you make a gRPC request (stream or RPC), the gRPC throughput load balancer will return the connection with the least number of active requests.
The order gRPC calls methods on the gRPC throughput load balancer are:
- Start
- Notify
- Up
- Get
lb := throughputlb.NewThroughputLoadBalancer(100, 20)
conn, err := grpc.Dial(os.Getenv("GRPC_ADDR"),
grpc.WithBalancer(lb))
if err != nil {
panic(err)
}