Load balancing while using gRPC

103 views
Skip to first unread message

ankitpa...@gmail.com

unread,
Feb 6, 2019, 5:50:06 PM2/6/19
to grpc.io
Hello 

I am exploring Load balancing  while using gRPC . So far i have gone through python quick start guide (hello world example); and it was easy to follow example. I have the same example running on two of my servers. 

Now I am in search for similar quick start with load balancing.  I went over https://grpc.io/blog/loadbalancing and similar pages which made sense to me but  at the same time i felt overwhelmed and cant figure out how and where to start. 

I want to start exercising simple code just like python hello world with load balancing enabled (when client say "hello"; load balancer decides which server to forward the request and respective server responds with "world" )

if you are aware of any such tutorials or reference links please help me out

thanks
Ankit 

Srini Polavarapu

unread,
Feb 10, 2019, 11:02:22 PM2/10/19
to grpc.io
Since you want to use an in-line load balancer, take a look at NGINX proxy that supports gRPC. In such a topology, the DNS points to your LB IP which gRPC clients connects to. LB will then load balance to backends. gRPC client is not aware of how many backends are present since it only talk to the LB in the middle. 

stefan lei

unread,
Nov 1, 2020, 9:28:53 PM11/1/20
to grpc.io
Hi Srini Polavarapu

How can I use client side load balancing in Python ?
Would you please show me some example ? 

Thinks !


Srini Polavarapu

unread,
Nov 8, 2020, 2:39:57 PM11/8/20
to grpc.io
You can specify client side round robin load balancing like this:

 opts = [("grpc.lb_policy_name", "round_robin",)] 
 channel = grpc.insecure_channel('<target>:<port>' , opts)

If your target address resolves to multiple addresses then requests are load balanced in a round robin fashion. Other than pick-first, this is the only built-in load balancing gRPC client supports

Reply all
Reply to author
Forward
0 new messages