[Python] How to enable the round-robin load balancing policy?

2,694 views
Skip to first unread message

pj2

unread,
Sep 20, 2017, 6:07:52 AM9/20/17
to grpc.io
Hi

I've looked around the GitHub project and I notice that round-robin is supported as a load balancing policy in gRPC core. Is there an option to set the policy in Python? Is there any documentation / parts of the code I can refer to?

Thanks

pj2

unread,
Sep 20, 2017, 6:47:04 AM9/20/17
to grpc.io
After digging around in core, I've found that this is the solution:

chan = grpc.insecure_channel("other-server.example.com", ("grpc.lb_policy_name", "round_robin"))

As a side note: it would be nice if ChannelArgKey contained lb_policy_name as a constant.

Thanks

pj2

unread,
Sep 20, 2017, 6:52:00 AM9/20/17
to grpc.io
Slight error: the last argument should be a list of tuples.

Amit Saha

unread,
Oct 7, 2017, 4:17:00 AM10/7/17
to grpc.io


On Wednesday, September 20, 2017 at 8:52:00 PM UTC+10, pj2 wrote:
Slight error: the last argument should be a list of tuples.

I have been trying to get my head around this (not yet looked deep enough). However, perhaps you would know - given that we have a single server address, how is the load balancing happening (and between what)? 

Thank you in advance.


pj2

unread,
Oct 7, 2017, 7:03:40 AM10/7/17
to grpc.io
Hello,

In my previous example, other-server.example.com is a DNS record which resolves to multiple IPs (each one running a gRPC server). Thus, the client will distribute requests over this channel evenly among these IPs.

Thanks

Amit Saha

unread,
Oct 7, 2017, 8:02:17 AM10/7/17
to grpc.io, pj2
On Sat, 7 Oct 2017 at 10:03 pm, 'pj2' via grpc.io <grp...@googlegroups.com> wrote:
Hello,

In my previous example, other-server.example.com is a DNS record which resolves to multiple IPs (each one running a gRPC server). Thus, the client will distribute requests over this channel evenly among these IPs.

I see, thank you. Do you by any chance have any reference to the code in gRPC core? Does it implement a higher level logic over the default getaddrinfo() [1] or similar on other systems?



Thanks


On Saturday, October 7, 2017 at 9:17:00 AM UTC+1, Amit Saha wrote:


On Wednesday, September 20, 2017 at 8:52:00 PM UTC+10, pj2 wrote:
Slight error: the last argument should be a list of tuples.

I have been trying to get my head around this (not yet looked deep enough). However, perhaps you would know - given that we have a single server address, how is the load balancing happening (and between what)? 

Thank you in advance.


--
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+u...@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/a9d0c8fb-d91e-461a-aa1f-b7dab8a6bfc6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

pj2

unread,
Oct 7, 2017, 10:18:54 AM10/7/17
to grpc.io
getaddrinfo is used in src/core/lib/iomgr/resolve_address_posix.cc.

The results of getaddrinfo is used by the DNS resolver (component which takes your target string and converts it into a list of addresses) at src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc.

Some relevant documentation may be found here:

Amit Saha

unread,
Oct 10, 2017, 7:57:54 AM10/10/17
to pj2, grpc.io
Great, thank you.

 

--
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+u...@googlegroups.com.
To post to this group, send email to grp...@googlegroups.com.
Visit this group at https://groups.google.com/group/grpc-io.

stefan lei

unread,
Nov 2, 2020, 2:19:58 AM11/2/20
to grpc.io
What's "other-server.example.com " ?  some grpc server ?
Reply all
Reply to author
Forward
0 new messages