[java] gRPC using custom NameResolver and Loadbalancer

212 views
Skip to first unread message

unknown person

unread,
Feb 19, 2018, 8:18:46 AM2/19/18
to grpc.io
I'm currently trying to figure out a way to create a custom NameResolver that uses Apache Zookeeper to get the servers for the Loadbalancer to balance between. I want client side Loadbalancing so I can balance between the servers with a key put into the metadata of a gRPC request.

The idea behind that is that clients (but server from the POV of gRPC) can register to listen to a specific topic in Zookeeper and then the servers (but clients from the POC of gRPC) connect to the clients and send that topic. The clients can also communicated with the servers in some way that they want do hold on to a specific partition for a period of time and that information will get to the LoadBalancer somehow (haven't figured that part out completely).

I'm not totally convinced what I'm trying to do is the right way for something like this but I haven't found any other solutions for this problem yet.

What would be the best way to do something like this?

Eric Anderson

unread,
Feb 21, 2018, 2:14:05 PM2/21/18
to unknown person, grpc.io
On Mon, Feb 19, 2018 at 5:18 AM, unknown person <spiel...@gmail.com> wrote:
I'm currently trying to figure out a way to create a custom NameResolver that uses Apache Zookeeper to get the servers for the Loadbalancer to balance between. I want client side Loadbalancing so I can balance between the servers with a key put into the metadata of a gRPC request.

The NameResolver should call onAddresses() with many EquivalentAddressGroups. Each EquivalentAddressGroup can have Attributes which can provide more information about that group, if necessary.

The LoadBalancer is passed that information, so the SubchannelPicker would have access to any needed routing tables (for those addresses). To do the actual routing, it can use PickSubchannelArgs.getHeaders() to retrieve the Metadata-supplied key. Note that it is also possible to put information in CallOptions via withOption() and retrieve them from the PickSubchannelArgs; this is functionally similar to Metadata except the key wouldn't be transmitted over the network.
Reply all
Reply to author
Forward
0 new messages