grpc/grpc-dotnet

[question] least connections GRPC load balancing

vrnmthr opened this issue · 2 comments

I understand that we can create a custom load balancer as per https://learn.microsoft.com/en-us/aspnet/core/grpc/loadbalancing?view=aspnetcore-5.0#create-a-custom-load-balancer.

I want to create a load balancer that sends requests to the endpoint with the least number of currently active connections. With the SubchannelsLoadBalancer, I can always know when I am "picking" a given subchannel (and thus I can increment its connection count). Is there any hook that I can call when a given request is completed (so I can decrement connection count)?

I am sure that this type of load balancing will be useful for many people. Perhaps it is worth adding into the library as an out of the box configurable option.

Because it was just an experiment. It also isn't perfect. It doesn't properly track long running streams. It only tracks calls until they return the first message.