Dubbo Cluster Fault Tolerance: A Source Code Walkthrough
This article provides a step‑by‑step analysis of Dubbo’s cluster fault‑tolerance mechanism, explaining the roles of Directory, Router, and LoadBalance, illustrating the execution flow with diagrams, and clarifying how invokers are selected and balanced in a distributed Java RPC framework.
The author originally planned a complete Dubbo source‑code series but decided to publish an early piece focusing on the important concept of cluster fault tolerance, assuming readers have some Dubbo usage experience and have read the official fault‑tolerant strategy overview.
To avoid the common problem of getting lost in deep call stacks, the article first presents an overall architecture diagram (the "map") and highlights three key keywords that appear throughout: Directory, Router, and LoadBalance.
After a brief environment setup (starting two providers and using Dubbo 2.5.4 source), the walkthrough begins with the consumer proxy class, showing that Dubbo injects a JDK dynamic proxy rather than a concrete implementation.
The execution then follows the numbered steps on the map: entering MockClusterInvoker , locating the Directory to retrieve all invokers, using Router (e.g., MockInvokersSelector ) to filter out only the normal invokers, and finally applying the LoadBalance strategy to pick the actual invoker for the call.
The article explains the default fault‑tolerance strategy (failover) and lists alternative cluster types such as Failfast, Failsafe, Failback, Forking, and Broadcast, each mapping to a specific implementation class.
It also notes that Dubbo’s default load‑balancing algorithm is random, which degrades to round‑robin when only two providers exist, and mentions a known bug in version 2.5.4.
In summary, the three core actions in Dubbo’s cluster fault‑tolerance are: (1) Directory finds all invokers, (2) Router selects the invokers that can execute normally, and (3) LoadBalance chooses one invoker based on the configured strategy.
The author promises future articles that will dive deeper into each of these three components and other core Dubbo modules, inviting readers to follow their updates.
Architecture Digest
Focusing on Java backend development, covering application architecture from top-tier internet companies (high availability, high performance, high stability), big data, machine learning, Java architecture, and other popular fields.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.