-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
balancer: refactor package base
into reusable components
#3425
Comments
Recently, we were trying to write a balancer and ran into a few issues that I wanted to share in case they could be used to influence the design of the updates to the balancer/base package. BackgroundWe wanted to create a balancer that preferred instances in a local availability zone if they were present, then preferred instances in a local region if they were present, and ultimately failed back to any instance globally. This could be used to reduce the round trip time and cost of requests. We used a custom resolver to set information on the ProblemWe wanted (ideally) this balancer to be composable with other balancers. So we could, for instance, indicate that a client should prefer local zones, but within a local zone, use round robin load balancing or consistent hashing, or whatever their current balancer is. We found it difficult to compose two balancers together given the current api and split between Current workaroundUltimately, we had to make a copy of any balancer we wanted to compose this balancer with and build a custom version of that balancer with exported internal types. Additional detailsA second example of wanting this composability is when we wanted to wrap our existing balancer with instrumentation. For example, we wanted to add spans around the balancer calls so we could more easily see when the addresses were updated in the balancer and how often addresses were being picked. In the issue description you mentioned reusable components and that might have also enabled us to solve this problem, but I guess it would depend on what reusable components balancer implementations would chose to export. |
@MatthewDolan Thanks for the information. That's very helpful. The first example you described sounds like a There might be another option to build this priority balancer with the reusable components. The advantage of the previous balancer-wrapper approach is it works for any balancers. The advantage of the components approach probably will be flexibility. The second example is something the reusable components can solve. |
Recently, we want to reduce the latency for internal communications between gRPC services. (before we are using linkerd as proxy to do the load balancing but it drops down the throughput) as I can see now, the balancer package all APIs in this package are experimental. so what should I be careful when using this package on production-grade. |
This is one possible way addressing of addressing the concerns of #2909. Closing this issue, and will leave other issue open until we decide how we want to handle this. |
Example of components:
connecting
afterready
an error state, instead of connecting.This helps decouple connection managing with RPC picking.
See more discussion in #3108
We should try to avoid adding features to the
base
balancer (thus causing API changes and/or complex code). The users are expected to build their own balancer with the reusable components, instead of based on thebase
balancer as a framework.The text was updated successfully, but these errors were encountered: