gRPC uses a "channel" rather than a "connection" as the surface level API. A channel is a managed set of connections to your server(s). The number of connections could drop down to 0 if they are idle, or be as large as every server returned by your DNS entries. gRPC has two pluggable components called a "name resolver" and a "load balancer" which both run inside of your client. The name resolver (typically DNS), converts the "target" string you connect to, and turns it into a set of addresses. The load balancer is notified of the addresses, and decides which ones to create connections to, and which ones received your RPCs. By default, we use a "pick first" load balancer which only makes one connection.
If the connection between a client and a particular server breaks, the connection is removed from the set, and if another connection is available, gRPC will fire RPCs on the healthy one. If not, gRPC will attempt to establish a new connection, up until the point that your RPC is not canceled or the deadline has exceeded. The word load balancer is overloaded here, because client side load balancing is different than server side. I think you are talking about server side. You will need to modify your client side load balancer to "round robin", which will establish connections to every backend server you have. When servers terminate, or are added to the pool of backends, it's up to the client side load balancer / name resolver to notice these differences and adjust the connections. gRPC does this by default (via the connections actually breaking), but it's faster if your name resolver (again, typically DNS) notices the server set has changed. On Friday, November 30, 2018 at 7:20:27 AM UTC-8, fairly accurate wrote: > > > Hello All, > I'm a newbie grpc user. Actually, i'm using a product that is built over > grpc. > I have read stuff about grpc, pardon my ignorance, some basic questions on > grpc connections. > > 1. I understand it is 1 connection per client server pair. Does this mean > a connection is established between client and server, and stays alive > until one of them ceases to exist ? > Also, if the connection drops, a new connection is initiated ? > > 2. I have a load balancer placed between the client and server. The LB has > 2 servers. In this case is 1 connection to each server or just one to LB > and the load is balanced between the tow servers or 2 connections ? > > Appreciate your response. > > AK > -- 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 [email protected]. To post to this group, send email to [email protected]. 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/18257045-84bf-4c07-b8ab-db8b5caee8d1%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
