00 Preface in Depth Mastery Dubbo Principles and Implementation to Enhance Your Competitive Edge in the Workplace

00 Preface In-Depth Mastery Dubbo Principles and Implementation to Enhance Your Competitive Edge in the Workplace #

Hello, I am Yang Sizheng. In the following period, we will explore Dubbo together.

I have worked in various Internet companies in fields such as e-commerce, new retail, short videos, and live streaming. During this time, I worked tirelessly in business operations, developed components in the infrastructure department, and designed architectures in the architecture department. Currently, I am still engaged in the development and maintenance of infrastructure-related work, mainly responsible for the development and operation of the company’s framework, RPC framework, database middleware, and other areas. I have delved into multiple open-source middleware and enjoy sharing my experiences and insights through code analysis.

Why Learn Dubbo #

When discussing any technology, we need to emphasize the business scenarios it applies to because the value of technology lies in solving business problems.

As a company grows, its business will continue to evolve, bringing with it increasing DAU, order volume, and data volume. The complexity of the systems supporting the business will also increase, as will the complexity of the dependencies between modules. At this point, we generally transition from a monolithic architecture to a cluster architecture (as shown in the figure below). In a cluster architecture, load balancing technology is used to distribute traffic evenly across all machines in the cluster, overcoming the limitations of a single machine’s hardware resources and achieving horizontal scalability.

Drawing 0.png

Monolithic Architecture vs. Cluster Architecture

Subsequently, due to the complexity and limited scalability of the business system’s implementation, poor code and feature reusability, we split a giant business system into multiple microservices and choose the most suitable hardware resources based on the different resource requirements of each service. For example, smaller services with less traffic may only require a cluster composed of a few machines, while core services require hundreds or thousands of machines to support them, maximizing the utilization of system resources.

Another benefit is the ability to reuse services at the service level, directly accessing the required service when needed, thereby improving development efficiency. After it is split into independent services (as shown in the figure below), the entire service can be maximally reused and can be more flexibly scaled.

Drawing 1.png

Microservices Architecture Diagram

However, in the process of implementing a microservices architecture, there are many problems to be solved, such as:

  • How to enable high-performance communication between services?
  • How to achieve load balancing, failover, and flow control for service calls?
  • How to effectively define service boundaries?
  • How to govern services?

Apache Dubbo is a high-performance and lightweight open-source Java RPC framework that provides three core capabilities:

  • Remote method invocation based on interfaces.
  • Reliable and intelligent fault tolerance and load balancing.
  • Automatic registration and discovery of services.

In simple terms, Dubbo is a distributed service framework that is dedicated to providing high-performance and transparent RPC remote service invocation solutions, as well as service governance solutions, to help us solve problems encountered in the implementation of microservices architectures.

Dubbo was originally developed by Alibaba and later joined the Apache Foundation. It has now graduated from the incubator and become a top-level project at Apache. Apache Dubbo currently has nearly 32.8K stars and 21.4K forks, which is a testament to its popularity. Many Internet giants, such as Alibaba, Didi, and Qunar, directly use Dubbo as their RPC framework. Some companies even build their own RPC frameworks based on Dubbo, such as DubboX of Dangdang.

As a Java engineer, gaining a deep understanding of the principles and implementation of Dubbo has become a trend and a key factor in your career competitiveness. According to Lagou.com, high-paying positions like research and development engineers and architects require you to be familiar with and have extensive experience with an RPC framework. Top-tier companies even require you to have at least a deep understanding of the principles and core implementation of an RPC framework.

Drawing 2.png

Drawing 3.png Drawing 4.png

(Source of position information: Lagou)

Dubbo is the preferred choice. Dubbo and Spring Cloud are currently the mainstream microservice frameworks. The infrastructure of Internet companies such as Alibaba, JD.com, Xiaomi, Ctrip, and Qunar has already been completed, and many subsequent projects are still based on Dubbo. After the reboot, Dubbo has already started planning version 3.0, and I believe there will be more amazing performances in the future.

In addition, the core principles and designs of RPC frameworks are similar. After reading the Dubbo source code, it will be very simple for you to understand the code of other RPC frameworks.

Pain points in reading Dubbo source code #

When learning and mastering a skill, it is generally done layer by layer: “what it is”, “how to use it”, and “why” (principles):

Drawing 5.png

Similarly, you can quickly understand what Dubbo is by reading the official documentation or a few introductory articles. Next, you can get hands-on experience by using Dubbo to develop several projects, thereby gaining a comprehensive understanding of Dubbo’s usage and features and becoming a “skilled worker”. However, many developers will not be satisfied with just writing business code every day. They will start studying the source code and underlying principles of Dubbo, which corresponds to the “principles” in the above figure.

When starting to read the source code, many developers will search for information online in advance or focus on studying the code directly. They commonly face some pain points due to this learning path:

  • There is a lot of online information, but most of it simply copies the Dubbo official documentation or pastes a bunch of Dubbo source code without any personal practice or experience sharing. It takes effort to learn but the harvest is not much.
  • The related materials describe an outdated version of Dubbo and have not kept up with the latest design and optimization, sometimes even misleading you. Or the focus is very narrow, only introducing one particular process of Dubbo. After reading it, you only know the relevant content on this specific call branch. Once the code runs to other places, you will still be confused.
  • If you read the Dubbo source code without referring to any materials, you need to have a certain technical background and a relatively high proficiency in the entire open-source project. Only then can you quickly grasp it by following its core logic. However, for a relatively unfamiliar open-source project, this may be a very painful process. The most fatal thing is that, due to the limited “vision” of the overall architecture, you are likely to get lost in the maze of code. Even though you spend a lot of effort reading and debugging the source code, you may still find it difficult to understand after closing IDEA.

Course setup #

I have previously shared analysis materials for various open-source projects and received unanimous praise from everyone. Therefore, I have decided to partner with Lagou Education to offer a series of courses. Based on my rich experience in analyzing open-source projects, I will guide you through reading the Dubbo source code. I hope to help you achieve a thorough understanding of Dubbo and apply it in practice, enabling you to extrapolate your knowledge.

Specifically, in this course, I will:

  • Start with the basics and use various demos to guide you step-by-step in analyzing the core knowledge points related to Dubbo. Afterwards, I will guide you to use these core technologies to write a simplified version of an RPC framework that connects all the knowledge points.
  • Guide you to analyze the Dubbo source code from the bottom up, deepening your understanding of Dubbo’s working principles and core implementation. This will enable you to go beyond the simple usage of Dubbo and understand both the “what” and the “why” aspects. For example, you can find answers to questions such as how providers publish services to the registry and how consumers subscribe to services from the registry.
  • Discuss the design patterns used in the Dubbo source code, allowing you to understand excellent practices of design patterns. This will help you go beyond theoretical knowledge and apply these design patterns when designing architectures and writing code. By doing so, you can make your code more extensible and maintainable.
  • Show you the latest optimizations and designs in Dubbo versions 2.7.5 and above, keeping you up-to-date with the latest trends and better applying them in your work practice.

Each knowledge point in this course is a step towards a deep understanding of Dubbo. The entire process of analyzing Dubbo’s implementation is like climbing to the top and becoming an expert. You can quickly understand the knowledge architecture of this course through the table of contents.

dubbo目录.png

Instructor’s message #

Lastly, I want to say: Immerse yourself in code, but don’t just immerse yourself in code.

The purpose of reading the source code is to improve your technical abilities, and the purpose of improving technical abilities is to better support business needs. Reading source code is not the end goal. You also need to combine it with practical business scenarios to better understand the design principles of open-source projects and apply them in practice.

Let’s embark on an exciting journey to explore Dubbo! I also hope you can share your learning experience, growth insights, and learning difficulties with me in the comments section. Learning is not a one-way output, but a process of exchanging feedback! Keep it up.

To facilitate your learning, I have uploaded the entire Dubbo source code (with comments) on GitHub. You can check it out as needed: https://github.com/xxxlxy2008/dubbo.