gRPCLB in gRPC Java 1.14

454 views
Skip to first unread message

Carl Mastrangelo

unread,
Jul 31, 2018, 2:30:41 PM7/31/18
to grpc.io
In release 1.14, it is now possible to use gPRC LB, gRPC's full featured load balancer client.  This is an experimental feature that contacts a gRPC LB server to get load balancing data.  

To get started, you will need to set the JVM flag "-Dio.grpc.internal.DnsNameResolverProvider.enable_grpclb=true", and include the grpc-grpclb artifact on your class path.  This enables using DNS SRV records to point to gRPCLB servers when doing load balancing.  

The DNS entries need to be in a specific format to be usable.   For a service called "api.service.com", It should look something like this:

A api.service.com - 127.0.0.1
AAAA api.service.com - ::1
lb.service.com - 192.168.0.1


gRPC will check for an SRV record with the prefix "_grpclb._tcp"   on the target you provide to the channel.  If present, gRPC will use the addresses of THAT domain as balancer addresses.  In LB parlance, lb.service.com is a *balancer* address, while api.service.com is a *backend* address.   Balanacer addresses must speak the gRPCLB protocol (as defined in the proto).

There will be upcoming documentation on the exact way to configure this, but this is being announced here for interested parties to try it out and answer any questions.

eleano...@gmail.com

unread,
Aug 17, 2018, 12:20:02 PM8/17/18
to grpc.io
Hi, 

I just wonder how does gRPC LB handles the bi-directional stream? Once it picks which server instance to serve the streaming request, then it will continue the streaming request only with that particular server?

Carl Mastrangelo

unread,
Aug 17, 2018, 3:29:15 PM8/17/18
to grpc.io
Yes, that is correct.   Load Balancing is done on a per-call basis.  Once an RPC has been assigned to a backend, it will continue on that backend.

eleano...@gmail.com

unread,
Aug 17, 2018, 5:07:47 PM8/17/18
to grpc.io
Thanks a lot for the clarification

Lisandro Diaz

unread,
Sep 6, 2018, 11:15:28 AM9/6/18
to grpc.io
Do i need to create my own loadbalancer or can i use the RoundRobin 
NettyChannelBuilder.forTarget(rpcTarget)
.loadBalancerFactory(RoundRobinLoadBalancerFactory.getInstance())
.nameResolverFactory(DnsNameResolverProvider.asFactory())
.negotiationType(NegotiationType.valueOf(rpcNegotiationType))
.build();

or do i need to use .loadBalancerFactory(GrpclbLoadBalancerFactory.getInstance())

Also the proto defined in grpclb is this meant to be served up by the loadbalancer (i.e: HAProxy) ? Which means i have to expose a grpc endpoint on HAProxy to reply with stats?

Carl Mastrangelo

unread,
Sep 6, 2018, 3:55:32 PM9/6/18
to grpc.io
It should be sufficient to have GrpclbLoadBalancerFactory in the classpath.  You can set it explicitly if you would like.


As for the endpoint, The load balancer and the load report are separate pieces.  The load balancer it the proto service that your client connects to and asks for server addresses and weights.  The load reporter service connects to your servers and asks them how loaded or alive they are.  Only the load balancer api was part of this release, and there currently isn't a load reporter.  I am considering showing how to make a simple one, but there isn't an off the shelf version for use yet.   

Lisandro Diaz

unread,
Sep 6, 2018, 4:05:01 PM9/6/18
to grpc.io
Thanks Carl!

blaze...@rtbhouse.com

unread,
Oct 17, 2018, 5:12:26 AM10/17/18
to grpc.io

On Tuesday, 31 July 2018 20:30:41 UTC+2, Carl Mastrangelo wrote:
There will be upcoming documentation on the exact way to configure this, but this is being announced here for interested parties to try it out and answer any questions.
(...) and there currently isn't a load reporter.  I am considering showing how to make a simple one, but there isn't an off the shelf version for use yet.   

Hi, I have a question: could you estimate (more\less) when those things are likely to happen? I mean more documentation on grpclb and ideas about load reporter.
I'm not asking about a specific date, only if it possible to be e.g. next 1-2 months or rather it will be a year?
Reply all
Reply to author
Forward
0 new messages