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

A question about Grpc load balancing and long connections #1032

Open
JanYork opened this issue Jan 18, 2024 · 3 comments
Open

A question about Grpc load balancing and long connections #1032

JanYork opened this issue Jan 18, 2024 · 3 comments
Labels
question A question about this library or its usage

Comments

@JanYork
Copy link

JanYork commented Jan 18, 2024

When I used Nacos+Grpc to perform multiple service load balancing tests, a question arose: the Grpc client initiated a request for the first time, and Grpc service A1 responded to the request. However, the GRPC client initiated a request for the second time, and Grpc service A2 responded. , the interval between the two requests is only 1.5s, but the responding servers are different. However, the bottom layer of Grpc uses netty for long-term connection communication, but two requests from the same client within 1.5 seconds are responded to by different servers. Does this mean that the Grpc client and Grpc server have long connections in a load-balanced environment? advantages will be lost?

@JanYork JanYork added the question A question about this library or its usage label Jan 18, 2024
@ST-DDT
Copy link
Collaborator

ST-DDT commented Jan 18, 2024

I think the default load balancing policy is round robin. You can overwrite that with the following config

public void setDefaultLoadBalancingPolicy(final String defaultLoadBalancingPolicy) {

Should we use a different default? 🤔

@JanYork
Copy link
Author

JanYork commented Jan 18, 2024

I think the default load balancing policy is round robin. You can overwrite that with the following config

public void setDefaultLoadBalancingPolicy(final String defaultLoadBalancingPolicy) {

Should we use a different default? 🤔

Thank you, but if I rewrite the load balancing algorithm, what kind of load balancing algorithm can retain the advantages of Netty's long connection?

@ST-DDT
Copy link
Collaborator

ST-DDT commented Jan 18, 2024

Pick first is pretty close, but it will (by default) only ever pick the first server in the list, instead of a random one.
There now is an option to shuffle it first, but I'm not sure how to configure that.

Maybe copy the file and just enable it by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question A question about this library or its usage
Projects
None yet
Development

No branches or pull requests

2 participants