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

consistent hash load balance多个consumer,同样的参数,不能分配到同一个provider节点 #352

Open
carycarter opened this issue Aug 10, 2017 · 0 comments

Comments

@carycarter
Copy link

RT, 发现在consistent hash计算virtual invokers时,同样的provider节点,算出来的hash是不同的。

for (Invoker invoker : invokers) {
for (int i = 0; i < replicaNumber / 4; i++) {
byte[] digest = md5(invoker.getUrl().toFullString() + i);
for (int h = 0; h < 4; h++) {
long m = hash(digest, h);
virtualInvokers.put(m, invoker);
}
}
}

同一个provider的 invoker.getUrl().toFullString() 最后的timestamp不相同,两个consumer上的结果如下:

dubbo://172.16.1.40:20880/com.test.demo.DemoService?anyhost=true&application=demo-consumer&check=false&dubbo=2.8.4&generic=false&interface=com.test.demo.DemoService&loadbalance=consistenthash&methods=sayHello&pid=68060&side=consumer&timestamp=1502361420315

dubbo://172.16.1.40:20880/com.test.demo.DemoService?anyhost=true&application=demo-consumer&check=false&dubbo=2.8.4&generic=false&interface=com.test.demo.DemoService&loadbalance=consistenthash&methods=sayHello&pid=68468&side=consumer&timestamp=1502361415516

导致的结果,多个consumer同时调用,同样的request并不能路由到同一个provider。

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

1 participant