当前位置:网站首页>Myrpc version 6
Myrpc version 6
2022-06-30 04:13:00 【Winter dream chaser】
RPC The concept of
Background knowledge
- RPC Basic concepts of , Core functions

common RPC frame
Duboo Basic function
- Telematics
- Transparent remote procedure call based on interface method
- Load balancing
- Service registry
RPC The process
client Call the remote method -> request serialize -> Protocol code -> Network transmission -> Server side -> Deserialization request -> Call the local method to get response -> serialize -> code ->……
Version iteration process
Catalog
from 0 At the beginning RPC Iterative process of :
- version0 edition : Complete a with less than 100 lines of code RPC Example
- version1 edition : Improve the common message format (request,response), The client's dynamic proxy completes the request Encapsulation of message formats
- version2 edition : Support the server to expose multiple service interfaces , Server program abstraction , Normalization
- version3 edition : Use a high-performance network framework netty The realization of network communication , And the refactoring of client code
- version4 edition : Custom message format , Support multiple serialization methods (java Native , json…)
- version5 edition : Implementation of server registration and discovery ,zookeeper As a registry
- version6 edition : Implementation of load balancing strategy
6.MyRPC edition 6
our RPC The overall framework already exists , Next, there are some modules that have expanded functions
Background knowledge
- Load balancing
Questions in this section
- If a service is supported by multiple providers , How to disperse the pressure of service providers
Upgrade process
- Load balancing interface
/** * Give the server address list , Choose one according to different load balancing strategies */
public interface LoadBalance {
String balance(List<String> addressList);
}
- Two ways of implementation
/** * Random load balancing */
public class RandomLoadBalance implements LoadBalance{
@Override
public String balance(List<String> addressList) {
Random random = new Random();
int choose = random.nextInt(addressList.size());
System.out.println(" Load balancing selects " + choose + " The server ");
return addressList.get(choose);
}
}
/** * Polling load balancing */
public class RoundLoadBalance implements LoadBalance{
private int choose = -1;
@Override
public String balance(List<String> addressList) {
choose++;
choose = choose%addressList.size();
return addressList.get(choose);
}
}
stay Service discovery methods Using load balancing in
List<String> strings = client.getChildren().forPath("/" + serviceName);
result
We started two service providers



It can be seen that the load balancing strategy has been successful
summary
In this version , We implement two strategies for load balancing : Random and polling .
In this version , A fully functional RPC Already appeared , Of course, there is still a lot of work to be done in terms of performance and code quality .
边栏推荐
- [Thesis reading | deep reading] role2vec:role based graph embeddings
- Simple theoretical derivation of SVM (notes)
- Grasp grpc communication framework in simple terms
- Day 10 data saving and loading
- Semantic segmentation resources
- el-upload上传文件(手动上传,自动上传,上传进度)
- Smart use of bitmap to achieve 100 million level massive data statistics
- Quick sort & merge sort
- 找到接口在表单里加参数
- Splicing strings with custom functions
猜你喜欢

(Reprinted) an article will take you to understand the reproducing kernel Hilbert space (RKHS) and various spaces

Thingsboard tutorial (II and III): calculating the temperature difference between two devices in a regular chain

I spent three years in a big factory outsourcing, which subverted my understanding!

Implementation of aut, a self-developed transport layer protocol for sound network -- dev for dev column

(03).NET MAUI实战 基础控件

An error occurs when sqlyog imports the database. Please help solve it!

绿色新动力,算力“零”负担——JASMINER X4系列火爆热销中

Troubleshoot abnormal video playback problems in public network deployment based on Haikang ehomedemo tool

Node red series (28): communication with Siemens PLC based on OPC UA node

接口测试--如何分析一个接口?
随机推荐
How to solve the problem of link hyperlinks when trying to link the database?
thinkphp5实现导入功能
节点CODE相同会导致数据重复
El upload upload file (manual upload, automatic upload, upload progress)
base64.c
If you encounter problems when using spark for the first time, please ask for help
在大厂外包呆了三年,颠覆了我的认知!
【WEBRTC】ADM: rtc_include_internal_audio_device 触发 RTC_DCHECK(adm) 断言
Use ideal to connect to the database. The results show some warnings. How to deal with this part
Troubleshoot abnormal video playback problems in public network deployment based on Haikang ehomedemo tool
Machine learning notes
el-upload上傳文件(手動上傳,自動上傳,上傳進度)
When easycvr deploys a server cluster, what is the reason why one is online and the other is offline?
A solution to the problem of "couldn't open file /mnt/repodata/repomd.xml"
Es2017 key summary
The same node code will cause duplicate data
Maya Calendar(POJ1008)
Geometric objects in shapely
2021-07-14
Day 12 advanced programming techniques