Reputation: 161
I am testing gRPC java client to its server over aws NLB load balancing but all traffics hit the same node. I try to understand how it would work over NLB.
As gRPC is using persistent TCP connection, I assume its client would establish multiple tcp connections over NLB to its server and randomly serve requests to those connections?
I am using the code from grpc.java example
ManagedChannel channel = ManagedChannelBuilder.forAddress(endPoint, port).usePlaintext().build();
GreeterGrpc.GreeterBlockingStub blockingStub = GreeterGrpc.newBlockingStub(channel);
response = blockingStub.sayHello(request);
I saw some docs said ManagedChannel encapsulates the complexity of connection pool and I suppose it will maintain connections and decide which connection to use?
Since stub is thread safe, I guess I could reuse the same stub for all requests?
So the problem is how I could make requests load balanced cross every server node. I ran the example over NLB but all requests hit the same node with no luck.
Upvotes: 0
Views: 1879
Reputation: 161
NLB can't load balance grpc properly. It's an inefficient hack.
grpc provides thick client side load balance solution for trusted client. https://github.com/grpc/grpc/blob/master/doc/load-balancing.md
Upvotes: 0