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

Best practices to use this library #27

Open
HFN opened this issue Feb 7, 2022 · 1 comment
Open

Best practices to use this library #27

HFN opened this issue Feb 7, 2022 · 1 comment

Comments

@HFN
Copy link

HFN commented Feb 7, 2022

Hi @sercand,

I have some questions about how to use this library and what are the best practices. Current README.md suggests to use this along with a client side load balancing policy. My question here is, Suppose grpc.Dial(...) has been already called and resolver respond with (let's say) 3 endpoints and therefore the returned conn from conn, err := grpc.Dial(...) with round_robin policy currently has a connection to each of these 3 endpoints. Now what happens if server scales up and increases the number of endpoints.

Am i expect to see the outgoing load also goes to new endpoints when using the old conn?
Do i need to Dial periodically or something?
What is the difference between using kuberesolver and a headless service?
What is the best practice to use this library?

I'll appreciate your time if you have any thoughts.

@sercand
Copy link
Owner

sercand commented Feb 19, 2022

Now what happens if the server scales up and increases the number of endpoints.

It is up to gRPC actually. kuberesolver gives IP addresses of newly created instances to gRPC and its handles rest. gRPC creates sub-connections for instances and disconnects from old ones. With gRPC retry middleware, you can retry your requests.

Am i expect to see the outgoing load also goes to new endpoints when using the old conn?

Yes

Do i need to Dial periodically or something?

No, you don't need to dial periodically. kuberesolver will provide newly created instances to gRPC and gRPC will create new subconnections.

What is the best practice to use this library?

Just register kuberesolver.RegisterInCluster() and dial with grpc.DialContext using round_robin, thats it.

What is the difference between using kuberesolver and a headless service?

headless service will give you the each IP address of pods but you need to check if they are changed. When using kuberesolver it watches service endpoint changes. Therefore when you deploy a new version of your app, gRPC automatically connects to new pods. With graceful termination policy, you will achieve zero downtime app deployments.

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

2 participants