Dubbo fault tolerance

Cluster fault tolerance

When the cluster call fails, Dubbo provides a variety of fault tolerance schemes, the default is failover retry.

cluster

The relationship of each node:

  • Here Invokeris Providera Servicecallable abstraction of , which Invokerencapsulates Provideraddress and Serviceinterface information
  • DirectoryRepresents multiple Invoker, you can think of it as List<Invoker>, but Listdifferent from , its value may change dynamically, such as registry push changes
  • ClusterDirectoryDisguise multiple in Invokeras one Invoker, which is transparent to the upper layer. The disguise process includes fault-tolerant logic. After the call fails, retry another
  • RouterResponsible for selecting subsets from multiple Invokers according to routing rules, such as read-write separation, application isolation, etc.
  • LoadBalanceResponsible Invokerfor s for this call. The selection process includes the load balancing algorithm. After the call fails, it needs to be re-selected.

Cluster fault tolerance mode

You can expand the cluster fault tolerance strategy by yourself, see: Cluster expansion

Failover Cluster

Automatically switch on failure, when a failure occurs, retry other servers 1 . Typically used for read operations , but retries incur longer delays. retries="2"You can set the number of retries (excluding the first time).

The number of retries is configured as follows:

<dubbo:service retries="2" />

or

<dubbo:reference retries="2" />

or

<dubbo:reference>
    <dubbo:method name="findFoo" retries="2" />
</dubbo:reference>

Failfast Cluster

Fast failure, only one call is made, and an error is reported immediately upon failure. Usually used for non-idempotent write operations , such as adding new records.

Failsafe Cluster: ignore failures

Fail safe, when an exception occurs, ignore it directly. Typically used for operations such as writing to the audit log.

Failback Cluster

The failure is automatically recovered, and the failed request is recorded in the background and retransmitted regularly. Typically used for message notification operations.

Forking Cluster

Call multiple servers in parallel and return as long as one succeeds. It is usually used for read operations with high real-time requirements , but it needs to waste more service resources. The maximum number of parallels can forks="2"be set by .

Broadcast Cluster

Broadcast to call all providers, call them one by one, and report error 2 if any one reports an error . Typically used to notify all providers to update local resource information such as caches or logs.

Cluster mode configuration

Follow the example below to configure cluster mode on the service provider and consumer


The setting method supports the following two ways to set, the priority is from low to high

<!--

        Failover failed automatic switching retries = "1" switching times

        Failfast fail fast

        Failsafe do not ignore failure

        Failback retry on failure, retry only once after 5 seconds

        Forking calls in parallel forks="2" maximum number of parallels

        Broadcast broadcast call

-->

<dubbo:service interface="..."cluster="broadcast" /> 

<dubbo:reference interface="..."cluster="broadcast"/  


Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326941776&siteId=291194637