Apache Dubbo编程指南系列之集群、负载均衡

Apache Dubbo提供了多种故障容忍策略如Failover、Failfast、Failsafe、Failback和Forking,以及负载均衡策略如Random、RoundRobin、LeastActive和ConsistentHash。本文详细介绍了这些策略的工作原理和应用场景。
摘要由CSDN通过智能技术生成

Fault Tolerance Strategy

当集群调用失败时,Dubbo提供了多种容错方案,并具有默认的故障转移重试功能。
在这里插入图片描述

  • This Invoker is the callable Service’s abstract of theProvider, and the Invoker packaging theProvider’s address and Service’s interface.
  • The Directory represent multiple Invoker,You can think of it as List<Invoker>,But unlike List,its value can be dynamically changing.such as registry push changes
  • The Cluster disguises multipleInvoker in Directory as aInvoker,The upper transparent, masquerade process contains fault-tolerant logic, call failed, try another
  • The Router is responsible for selecting subsets according to routing rules from multiple Invokers, such as read-write separation, application isolation, etc.
  • LoadBalance is responsible for selecting a specific one from multipleInvoker for this call. The selection process includes the load balancing algorithm. If the call fails, it needs to be re-selected

策略详解

  • Failover Cluster - 故障自动切换,出现故障时,请重试其他服务器(默认)。通常用于读取操作,但是重试会导致更长的延迟。重试次数可以通过重试= 2设置(不包括第一次)。
<!--默认配置-低优先级-->
<dubbo:consumer check="true" registry="zk_registry" application="app1" retries="2" timeout="1000" />

<!--实例中局部配置-中优先级-->
<dubbo:reference id="userService" interface="com.baizhi.service.IUserService" retries="2"
                 registry="zk_registry"
                 application="app1" 
                 timeout="1000">
    <!--方法配置-高优先级-->
    <dubbo:method name="save" retries="2" timeout="500"/>
</dubbo:reference>

或者

<!--默认配置-低优先级-->
<dubbo:provider retries="2" protocol="dubbo_protocol" application="app1" registry="zk_registry"/>
<!--实例中局部配置-中优先级-->
<dubbo:service interface="com.baizhi.service.IUserService" ref="userService"
               protocol="dubbo_protocol"
               application="app1"
               registry="zk_registry"
               retries="2" >
    <!--方法配置-高优先级-->
    <dubbo:method name="save" retries
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值