• 周六. 7 月 13th, 2024

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

How can I quickly master the principle and source code of Dubbo (pure dry goods) in a short time?

King Wang

1 月 4, 2022
## Written in front last week , stay 【Dubbo Series of special topics 】 Two articles have been updated in 《[ The glacier began to respond to Dubbo Let’s go !](https://mp.weixin.qq.com/s?__biz=Mzg4MjU0OTM1OA==&mid=2247489794&idx=1&sn=aa9efb732ac7fe3d2bc927c1491cae57&chksm=cf55ae03f82227157bb69cb487df2081b5b623d173b1df603be66347692acec56d455da6aae1&token=942113583&lang=zh_CN#rd)》 and 《[ overlooking Dubbo Global , You have to master these before you read the source code !!](https://mp.weixin.qq.com/s?__biz=Mzg4MjU0OTM1OA==&mid=2247489831&idx=1&sn=e1126303a91f8fccb6154196695c5e6e&chksm=cf55ae26f82227302f71ced14c0aa312f631c8f03df65650dd3a49dc7fa9f339685342c38f5a&token=942113583&lang=zh_CN#rd)》, Received a lot of wechat private chat messages from small partners , Most of them are asking how to master it quickly Dubbo Principle and source code . In response to this question , I’m also thinking about how to make it easier 、 Easy to understand way to let the children better grasp Dubbo Principle and source code . today , I’ll share with my friends how I quickly mastered Dubbo The principle and source code of . The article has been included in :[https://github.com/sunshinelyz/technology-binghe](https://github.com/sunshinelyz/technology-binghe)[https://gitee.com/binghe001/technology-binghe](https://gitee.com/binghe001/technology-binghe)## Read the premise of the original code, read a technical framework , Or the source code of an open source project , You have to understand what this framework is for , To put it bluntly , At least you know how to use this framework , In what kind of scene to use , Which pits will be encountered in the process of using , How to solve . And learn a framework , The easiest and most effective way to do that is to have its official documents .Dubbo No exception , I’m learning Dubbo When , It’s also the first thing to see Dubbo Official documents of , I didn’t read any other articles or materials . Why ? Because Dubbo The most authoritative official document is , It’s the most credible . Even if you haven’t used it in a project Dubbo frame , You can also follow Dubbo Our official documents are based on Dubbo Write a simple example program , Through examples, you can quickly understand Dubbo.## Why read the source code? Before reading the source code , You need to know exactly why you read the source code , Look at the original code with questions . ** Want to see the source code of the frame , There are only two situations : One is the problem that cannot be solved by files or other technical data in the project , Want to find a solution through the source code ; The other is to be curious about the underlying implementation of the framework , How does this awesome technology come true ?** And I’m , It basically belongs to the latter . In the high parallel power system with hundreds of millions of users that I have experienced , Some core subsystems use Dubbo, After performance tuning ,Dubbo I’m doing well . I’m curious :Dubbo How to resist such high concurrency ? How it’s done internally ? secondly , Before reading the source code , You have to ask yourself a few questions , For example, I’m watching Dubbo Before the source code , A lot of questions have been made clear , such as :Dubbo How to achieve RPC Serving ? How do service providers and callers interact ?Dubbo How to encapsulate a network call to make it look like a local call ?Dubbo And how to achieve service governance ? And so on, a series of questions , I remember looking at the source code , I asked myself hundreds of questions .** Look at the source code with questions , It can make you get twice the result with half the effort , It’s not just Dubbo, For other frameworks , So it is with .** And then there’s the , Don’t look at the source code just to look at it , A lot of partners have seen the original code of many frames , But it didn’t take long to forget , It’s like not watching , And wasted a lot of time . This is a typical way to look at the source code for the sake of looking at the source code , I didn’t go into the implementation principles and details of this framework , When you don’t understand , You can skip , Record , After reading the associated code , Turn around and rearrange the original code that you don’t understand .## What techniques does the framework use before reading the source code , Another important task is , To understand what technologies are used in the framework . Have a general understanding of the technology used . such as : stay Dubbo Used in SPI、 Time wheel timing task 、 Service registration and discovery 、Netty、 serialize 、 Custom protocol and so on . therefore , Before reading the source code , First of all, we need to have a general understanding of these technologies . such as , Looking at Dubbo Before the source code , I’ve learned that Dubbo The bottom layer of network interaction uses Netty, Just when I was working for a while , I’ve studied it in depth Netty The original code of , It helps me to see Dubbo When the source code is , Can better understand Dubbo The network programming part of . So , One minute on stage , Ten years on stage , Looking at Dubbo Before the source code , I’m also well prepared .## When reading the source code, pay attention to any technical framework , Or open source projects , It must have been created to solve some scenes , Like Dubbo, I believe all of you know ,Dubbo As a decentralized service governance framework , A typical use scenario is distributed system . secondly , An excellent technical framework or open source project must contain the principles and implementation of many other technologies . We also use Dubbo For example , stay Dubbo in , In order to achieve in a decentralized scenario , Call the far end RPC Services are like calling local services , At least it needs to realize the following functions :* Communication between services .* Service calls need to be load balanced 、 High availability 、 Current limiting .* Service governance .* Highly reliable 、 Fault tolerance .* Services can automatically register and discover . And when you implement these functions ,Dubbo Thanks to the excellent open source frameworks ? These open source frameworks Dubbo How is it integrated ? It’s hard coded integration ? Or something better ? All of these require us to read the source code , Go to the source code and find the answer .## The way to read the source code I summarize the way to read the source code as :** First the whole and then the region , First macro view, then micro view , First rough, then detail .** What do you mean ? It’s time to look at the source code , First, grasp the design principle and design concept of the original code as a whole , Let’s first have a general understanding of how the source code is implemented . For example Dubbo in , Network programming is based on Netty Realized , You can get to know , I know that . After grasping the basic frame source code as a whole , And then from the details of the specific implementation , such as , stay Dubbo How to use Netty To achieve network interaction ?** Remember , Do not read the original code before you understand the overall design principle and the overall original code design , Just start sticking to the details of the source code . Otherwise , You will lose yourself in the source code .**## How to verify that you have the source code ? Reading the source code is not enough , I have to do it myself , So called “ Practice is the only standard for mastering arrangement ”. You don’t practice , How do you know if you have mastered . I divide the practice part into two parts :** Practice in the process of looking at the source code ; Practice after looking at the source code .** In the process of looking at the source code, hands-on practice means : In the process of looking at the source code , Write down what you don’t understand , Look up the official website documents or other information , If it’s due to a lack of technical ability , Cannot read , It’s time to recharge yourself to supplement the relevant knowledge . If it’s a better way to realize it , You can mark your understanding with comments on the code of the framework . such as , I was watching Dubbo At the time of the original code , A lot of comments . After looking at the source code , Be sure to practice . Yes Dubbo After the whole source code of , If you think you have Dubbo, You can do it yourself RPC frame , Take a look at the framework and Dubbo What’s the difference between frameworks , Why Dubbo The framework is implemented in this way . Turn around and look at it with questions Dubbo The original code of , You’re going to understand more . And I’m , After reading Dubbo After the original code of the frame , It’s the same thing .## Read the summary of the source code ** Finally , Let’s talk to our friends : I see from the beginning Dubbo Source code , To grasp Dubbo Principle and source code , It took less than two months . Remember , Before reading the source code , Make sure you know why you read the source code , Read the source code with questions , For other technologies or frameworks involved in the source code , Be sure to understand . In the process of reading the source code , To follow : First the whole and then the region , First macro view, then micro view , The principle of rough first and then detailed . The most important point is : In the process of reading the original code and after reading the original code, we should practice it .**** Okay , That’s all for today , I’m glacier , If you have any questions, please leave a message below , I can also add wechat , Communicate technology together , Step up together , Together

发表回复