Fault Tolerance Strategy
当集群调用失败时,Dubbo提供了多种容错方案,并具有默认的故障转移重试功能。
- This
Invoker
is the callable Service’s abstract of theProvider
, and theInvoker
packaging theProvider
’s address andService
’s interface. - The
Directory
represent multipleInvoker
,You can think of it asList<Invoker>
,But unlikeList
,its value can be dynamically changing.such as registry push changes - The
Cluster
disguises multipleInvoker
inDirectory
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 multipleInvoker
s, 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