[C++] load balancing?

336 views
Skip to first unread message

tud...@gmail.com

unread,
Apr 18, 2017, 11:46:46 AM4/18/17
to grpc.io
Hello,

What's the status of load balancing (https://github.com/grpc/grpc/blob/master/doc/load-balancing.md) in C++?

It seems that the "grpclb" implementation exists in core, but there's no way to obtain addresses with is_balancer=true (the DNS resolvers always assume that resolved addresses are regular backend addresses as opposed to balancer addresses; the calls to grpc_lb_addresses_set_address always set is_balancer=false).

Right now, I'm planning to multiplex on my side onto a pool of channels (I'm using Kubernetes iptables forwarding, which looks like a L4 balancer from the client side -- all nodes are hidden behind the same IP address), but I'd be willing to switch to grpclb when it becomes available.

Also, are there any plans to provide grpclb servers for common use cases (balancing to one Kubernetes service would be a very useful one, and would probably get a lot of usage).

Thanks,
-Tudor.

David Garcia Quintas

unread,
May 30, 2017, 8:29:01 PM5/30/17
to grpc.io, tud...@gmail.com
Hi Tudor,

Apologies for the late response. It's timely that the PR that adds support for the c-ares DNS resolver (https://github.com/grpc/grpc/pull/11237) is very close to being merged. This is the piece that's missing for making grpclb work in open source. In particular:
  • Have a look at this document. It goes over the DNS configuration changes needed to control which addresses are marked as balancers. It's currently a "proposal", to be promoted to a doc shortly. It can be taken quite authoritatively, it's what https://github.com/grpc/grpc/pull/11237 is implementing for balancer discovery.
  • Wait for https://github.com/grpc/grpc/pull/11237 to be merged, or patch it in a local repo.
  • Write a regular gRPC server (in any language) implementing the load balancer protocol. This is the server to be marked in your DNS records as a balancer (as described in the aforementioned document), with which the client's grpclb will talk to to obtain the list of backend addresses (what's called server_lists). It's up to you to make the logic inside this balancer as simple or as complex as you want.
Let me know if you have any questions, I'll be more prompt to get back to you this time around :)
David.

David Garcia Quintas

unread,
May 30, 2017, 8:57:20 PM5/30/17
to grpc.io, tud...@gmail.com
Also, for completeness: the client would use the DNS name of the balancer when creating a channel. Note also that your balancer DNS name may point to several addresses. If one or more of them are marked as balancers, grpclb will be used. Which balancer will be picked up if there's more than one? The first one the client connects to.

谭锦彪

unread,
Aug 13, 2017, 9:44:41 AM8/13/17
to grpc.io, tud...@gmail.com
Hi David,

Is grpclb available now? since the PR that adds support for the c-ares DNS resolver has being merged. But the calls to grpc_lb_addresses_set_address still always set is_balancer=false in dns_resolver_ares.c, that confused me.

在 2017年5月31日星期三 UTC+8上午8:29:01,David Garcia Quintas写道:

Mark D. Roth

unread,
Aug 14, 2017, 10:45:02 AM8/14/17
to 谭锦彪, grpc.io, tud...@gmail.com
I think you must be looking at code that does not include that PR.  With that PR, there are no calls to grpc_lb_addresses_set_address() in dns_resolver_ares.c; those calls have been moved to grpc_ares_wrapper.c, and the is_balancer parameter is set to true for balancer addresses:

https://github.com/grpc/grpc/blob/master/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.c#L176

Hope this helps.

--
You received this message because you are subscribed to the Google Groups "grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email to grpc-io+unsubscribe@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit https://groups.google.com/d/msgid/grpc-io/e769124d-fded-4bac-8dbc-cf4ce153d9f5%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Mark D. Roth <ro...@google.com>
Software Engineer
Google, Inc.
Reply all
Reply to author
Forward
0 new messages