Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Add basic client side load balancing for gRPC #417

Open
vermas7988 opened this issue Dec 1, 2024 · 6 comments
Open

Feature request: Add basic client side load balancing for gRPC #417

vermas7988 opened this issue Dec 1, 2024 · 6 comments

Comments

@vermas7988
Copy link

There is no client side load balancing for gRPC module.
All the requests land on one instance rather than distributing the load between multiple instances.
Is it possible to add basic load balancing on client side e.g. round_robin or other pattern so request load can be distributed among instances?

@pjfanning
Copy link
Contributor

https://pekko.apache.org/docs/pekko-grpc/current/client/details.html#load-balancing

Does this cover your use case? The docs seem to indicate that we rely on grpc-java, a separate lib, for a lot of this support. If the existing support does not suit you, can you indicate what extra you are looking for?

@pjfanning pjfanning transferred this issue from apache/pekko Dec 1, 2024
@vermas7988
Copy link
Author

As mentioned in the link you shared, "When multiple endpoints are discovered for a gRPC client, currently one is selected and used for all outgoing calls". Ideally we should be able to send requests to both endpoints in a round_robin fashion.
Even if round_robin is provided as load balancing policy, only one host is receiving requests.

I see in the docs, "Client-side load balancing is desirable when you are using the default static or the grpc-dns discovery mechanism.". But the meaning of default static method is not clear to me. Can we add some example for this use case?

Also, I searched on internet for client side load balancing for akka-grpc with akka discovery and found old merge in akka grpc:(akka/akka-grpc#809)

@pjfanning
Copy link
Contributor

That akka-grpc PR is in Pekko gRPC. The fork was made after the merge was made.

@vermas7988
Copy link
Author

indeed, but there is no clear doc/explaination on how to achieve client side load balancing, even with the default static mechanism as I mentioned in above comment.

@pjfanning
Copy link
Contributor

pjfanning commented Dec 1, 2024

I will repeat pekko-grpc is built on top of grpc-java and https://pekko.apache.org/docs/pekko-grpc/current/client/details.html#load-balancing highlights how to set the load-balancing-policy config. You can go and read the grpc-java docs to find out what the settings are (we already list round_robin as being supported). Apache Pekko is a free lib with no warranties or support. You can help by coming back with what you learn and add to the pekko-grpc docs to help future users.

@raboof
Copy link
Member

raboof commented Dec 2, 2024

As mentioned in the link you shared, "When multiple endpoints are discovered for a gRPC client, currently one is selected and used for all outgoing calls".

We should probably add a 'by default' there.

Ideally we should be able to send requests to both endpoints in a round_robin fashion. Even if round_robin is provided as load balancing policy, only one host is receiving requests.

As that documentation mentions, while perhaps counter-intuitive, there are situations where that's a better strategy - but I agree it would be good if client-side load balancing were possible.

I see in the docs, "Client-side load balancing is desirable when you are using the default static or the grpc-dns discovery mechanism.".

I suspect we should replace 'desirable' with 'possible' here.

But the meaning of default static method is not clear to me.

'static' is the discovery method that is used when you don't configure a different service discovery mechanism (https://pekko.apache.org/docs/pekko-grpc/current/client/configuration.html#using-pekko-discovery-for-endpoint-discovery).

Can we add some example for this use case?

I agree that would be helpful.

Even if round_robin is provided as load balancing policy, only one host is receiving requests.

Indeed that seems to contradict the documentation. Could you boil down your application to a minimal test project to show the behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants