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

希望dtm可以支持grpc的balancer扩展,比如一致性hash的方式访问目标服务 #363

Open
nearmeng opened this issue Oct 26, 2022 · 5 comments

Comments

@nearmeng
Copy link

目前dtm支持扩展grpcresolver以及服务注册的内容,但是对资源服务的grpc访问采用的是默认的balancer方式,希望可以对该负载均衡方式支持扩展

@nearmeng nearmeng changed the title 希望dtm可以支持grpc的balancer扩展,比如一致性hash地方式访问目标服务 希望dtm可以支持grpc的balancer扩展,比如一致性hash的方式访问目标服务 Oct 26, 2022
@yedf2
Copy link
Contributor

yedf2 commented Oct 26, 2022

有没有相关的使用场景,以及grpc的解决方案的资料,给一个?

@nearmeng
Copy link
Author

使用的场景:
正常应用对微服务的访问采用一致性hash的方式进行访问,需要事务也按照一致性hash进行执行

下面是网上找的示例:
https://lxkaka.wang/gprc-balancer/

@xyctruth
Copy link
Contributor

xyctruth commented Oct 26, 2022

dtmdriver 中提供的 RegisterAddrResolver 接口应该就满足扩展了吧?

https://github.com/dtm-labs/dtmdriver/blob/96d229722f19449a0e02a2a24ab8375c912d597a/driver.go#L16

@nearmeng
Copy link
Author

RegisterAddrResolver 这个是可以注册一些扩展的balancer实现进去,不过dtm grpc dial时如何设置合适loadBalancingPolicy,以及如何对每个执行事务分支使用不同的hash_key,这些还没有支持

@wuqinqiang
Copy link
Contributor

这个感觉是需要的,默认grpc 走的是pick_first,但是实际情况机器可能拥有不同的权重,承接请求量不一样。用户也应该可以在客户端选择不同的picker策略,甚至可以开放接口让用户自定义自己的策略。

我目前是自定义一个balancer.PickerBuilder,
在里面提供不同的策略,客户端新增一个option,在 grpc dial 连接之前根据选择的策略类型向grpc register自定义balancer.PickerBuilder。

相关:
https://github.com/grpc/grpc/blob/master/doc/load-balancing.md
https://github.com/grpc/grpc/blob/master/doc/service_config.md

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

4 participants