dangdangdotcom / dubbox

Dubbox now means Dubbo eXtensions, and it adds features like RESTful remoting, Kyro/FST serialization, etc to the Dubbo service framework.
http://dangdangdotcom.github.io/dubbox
Apache License 2.0
4.89k stars 2.06k forks source link

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

Open carycarter opened 7 years ago

carycarter commented 7 years ago

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。