当前位置:网站首页>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 .
边栏推荐
猜你喜欢

Machine learning notes

How to solve the problem of link hyperlinks when trying to link the database?

尝试链接数据库时出现链接超时报错,如何解决?

El upload upload file (manual upload, automatic upload, upload progress)

基于ROS的SLAM建图、自动导航、避障(冰达机器人)

Sql语句遇到的错误,求解

Cloud native -- websocket of Web real-time communication technology

dotnet-exec 0.5.0 released

RPC correction

第九天 脚本与资源管理
随机推荐
[fuzzy neural network prediction] water quality prediction based on fuzzy neural network, including Matlab source code
【WEBRTC】ADM: rtc_include_internal_audio_device 触发 RTC_DCHECK(adm) 断言
MySQL DDL change
找到接口在表单里加参数
声网自研传输层协议 AUT 的落地实践丨Dev for Dev 专栏
Implementation of aut, a self-developed transport layer protocol for sound network -- dev for dev column
[Thesis reading | deep reading] role2vec:role based graph embeddings
Modifier of JS regular expression
管道实现进程间通信之命名管道
Robot slam navigation core technology and practice Season 1: Chapter 0_ Slam development overview
base64.c
Titanic(POJ2361)
AI落地的新范式,就“藏”在下一场软件基础设施的重大升级里
Educoder group purchase suspension box page production
节点CODE相同会导致数据重复
[operation] MySQL query on May 24, 2022
The new paradigm of AI landing is "hidden" in the next major upgrade of software infrastructure
(03). Net Maui actual combat basic control
使用IDEAL连接数据库,运行出来了 结果显示一些警告,这部分怎么处理
RPC correction