-
Notifications
You must be signed in to change notification settings - Fork 26.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
为什么即使在服务端没有上下线操作的时候一致性hash负载均衡算法每次都需要重新进行hash环的映射? #5424
Comments
自定义的负载均衡算法和Dubbo 2.7.4.1 版本的一样,除了加了几句输出语句:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Environment
为了更好的研究一致性hash负载均衡策略,我自定义了一个SPI。
whyConsistentHash=com.example.dubbo.loadbalance.provider.loadbalance.WhyConsistentHashLoadBalance
我加入了几行输出代码如下:
同时为了演示方便,我调整了虚拟节点数为4:
<dubbo:parameter key="hash.nodes" value="4"></dubbo:parameter>
这样就是2个服务端,
启动两个服务端。这样就是2个服务端,一个服务端有4个虚拟节点,共计8个节点。
客户端调用如下:
最后输出结果为:
是新的invoker :418299920,原:null
key=447653163,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@67c119b7
key=488050138,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@67c119b7
key=724509126,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@67c119b7
key=2033828652,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@2ca5f1ed
key=2496774652,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@67c119b7
key=3155964929,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@2ca5f1ed
key=4068105014,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@2ca5f1ed
key=4223326152,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@2ca5f1ed
是新的invoker :105393903,原:418299920
key=447653163,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@67c119b7
key=488050138,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@67c119b7
key=724509126,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@67c119b7
key=2033828652,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@2ca5f1ed
key=2496774652,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@67c119b7
key=3155964929,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@2ca5f1ed
key=4068105014,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@2ca5f1ed
key=4223326152,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@2ca5f1ed
是新的invoker :533698361,原:105393903
key=447653163,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@67c119b7
key=488050138,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@67c119b7
key=724509126,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@67c119b7
key=2033828652,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@2ca5f1ed
key=2496774652,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@67c119b7
key=3155964929,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@2ca5f1ed
key=4068105014,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@2ca5f1ed
key=4223326152,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@2ca5f1ed
是新的invoker :1531545666,原:533698361
key=447653163,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@67c119b7
key=488050138,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@67c119b7
key=724509126,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@67c119b7
key=2033828652,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@2ca5f1ed
key=2496774652,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@67c119b7
key=3155964929,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@2ca5f1ed
key=4068105014,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@2ca5f1ed
key=4223326152,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@2ca5f1ed
是新的invoker :481525476,原:1531545666
key=447653163,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@67c119b7
key=488050138,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@67c119b7
key=724509126,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@67c119b7
key=2033828652,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@2ca5f1ed
key=2496774652,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@67c119b7
key=3155964929,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@2ca5f1ed
key=4068105014,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@2ca5f1ed
key=4223326152,value=org.apache.dubbo.registry.integration.RegistryDirectory$InvokerDelegate@2ca5f1ed
在过程中并没有服务上下线的操作,为什么5次调用,每次都会重新进行hash环的映射。而且从输出可以看出,每次映射的结果是一样的。
我看了invokers在这五次调用的时候地址值确实不一样。但是我不明白为什么?求解答。
The text was updated successfully, but these errors were encountered: