缺省用 160 份虚拟节点,如果要修改,请配置 <dubbo:parameter key="hash.nodes" value="320" />
配置一般在项目中不会在代码层面指定权重,而是通过监控中心(dubbo-admin)对服务动态的指定权重,官方文档:
xml服务端服务级别
<dubbo:service interface="..." loadbalance="roundrobin" weight="100" />客户端服务级别
<dubbo:reference interface="..." loadbalance="roundrobin" />服务端方法级别
<dubbo:service interface="..." weight="100"> <dubbo:method name="..." loadbalance="roundrobin"/> </dubbo:service>客户端方法级别
<dubbo:reference interface="..."> <dubbo:method name="..." loadbalance="roundrobin"/> </dubbo:reference> yaml dubbo: provider: loadbalance: roundrobin weight: 100 consumer: loadbalance: roundrobin 注解 @Service(loadbalance = "roundrobin", weight = 100) @Reference(loadbalance = "roundrobin")