当前位置:网站首页>RPC details

RPC details

2022-06-11 00:44:00 A music loving programmer


One 、RPC What is it? ?

RPC(Remote Procedure Call) Remote procedure call protocol , An application is deployed in A Server , Want to call B Application provided function methods on the server , Because it's not in a memory space , Can't call directly , We need to express the semantics and data of the call through the network .

​ RPC The protocol allows one host program to call another host program in the Internet , Programmers do not need to program this interaction process . stay RPC The agreement stresses that A Program call B When a function or method in a program ,A I don't know B The specific implementation of the method in .

​ RPC It's the upper level agreement , The bottom layer can be based on TCP agreement , It can also be based on HTTP agreement . Generally speaking, we say RPC It's all based on RPC The concrete realization of , Such as :Dubbo frame . In a broad sense, as long as it meets the requirements of communication calls in the network, it is collectively referred to as RPC, even to the extent that HTTP Agreements can be said to be RPC The concrete realization of , But the specific analysis seems RPC The agreement is better than HTTP More efficient protocol , be based on RPC The framework has more functions .

​ RPC The protocol is based on the distributed architecture , therefore RPC It has unique advantages in distributed projects .

Two 、RPC and HTTP contrast

1. Concrete realization

​ RPC: Can be based on TCP agreement , It can also be based on HTTP agreement .

​ HTTP: be based on HTTP agreement

2. efficiency

​ RPC: Customizing the concrete implementation can reduce many useless message contents , Make the message volume smaller .

​ HTTP: If it is HTTP 1.1 Many contents in the message are useless . If it is HTTP2.0 Later and RPC Little difference , Than RPC Less likely are some functions such as service governance .

3. How to connect

​ RPC: Long connection support .

​ HTTP: Every connection is 3 The second handshake .

4. performance

​ RPC: Can be based on many serialization methods . Such as :thrift

​ HTTP: Mainly through JSON, Serialization and deserialization are less efficient .

5. Registry Center

​ RPC : commonly RPC All have a registration center .

​ HTTP: It's all direct connection .

6. Load balancing

​ RPC: most RPC The frameworks all have load balancing measurements .

​ HTTP: Third party tools are usually required . Such as :nginx

summary

RPC Frameworks generally have rich functions such as service governance , It is more suitable for enterprise internal interface calls . and HTTP It is more suitable for mutual calls between multiple platforms .

原网站

版权声明
本文为[A music loving programmer]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203020627519809.html