current position:Home>Why not use - HTTP - instead of - RPC for calls between services?, Tencent background development

Why not use - HTTP - instead of - RPC for calls between services?, Tencent background development

2021-08-21 13:19:04 Programmer's secret place

Here's another online sequence diagram :

RPC What problems have been solved ?

From above RPC In the content of the introduction , A nutshell RPC Mainly solved : Make calls between different services in a distributed or microservice system as simple as local calls .

common RPC Framework summary ?

  • RMI(JDK Bring their own ):?JDK Self contained RPC, There are many limitations , It is not recommended to use .

  • Dubbo:?Dubbo yes Alibaba open source a high-performance excellent service framework , Enables applications to pass high-performance RPC Realize the output and input functions of services , You can talk to Spring Seamless integration of framework . at present Dubbo Has become a Spring Cloud Alibaba The official component in .

  • gRPC?:gRPC It's a modern open source high performance that can run in any environment RPC frame . It can effectively connect services within and across data centers through pluggable support , To achieve load balancing , track , Health checks and authentication . It also applies to the last mile of Distributed Computing , To put the equipment , Mobile applications and browsers connect to back-end services .

  • Hessian:?Hessian It's a lightweight remotingonhttp Tools , Using a simple method provides RMI The function of . comparison WebService,Hessian It's simpler 、 quick . It's binary RPC agreement , Because it uses binary protocol , So it's good for sending binary data .

  • Thrift:?Apache Thrift yes Facebook Open source, cross language RPC Communication framework , It has been donated to Apache Foundation management , Because of its cross language features and excellent performance , It's used by many Internet companies , Companies with capabilities can even be based on thrift Develop a distributed service framework , Add services such as registration 、 Service discovery and other functions .

both HTTP , Why RPC Make service calls ?

###RPC It's just a design

RPC It's just a concept 、 A design , Just to solve it ? Call between different services , It usually contains ? Transfer protocol ? and ? Serialization protocol ? these two items. .

Realization RPC The transport protocol can be built directly on TCP above , It can also be built on HTTP The agreement above . Most of the RPC Frameworks are used TCP Connect (gRPC Used HTTP2).

HTTP and TCP

Maybe now many friends who are not familiar with computer network have been confused , To really understand , Also need to briefly review the basic knowledge of computer network :

We usually talk about the architecture of five layer protocol of computer network : application layer 、 Transport layer 、 The network layer 、 Data link layer 、 The physical layer .

** application layer (application-layer) The task is to complete a specific network application through the interaction between application processes .**HTTP Belongs to the application layer protocol , It will be based on TCP/IP Communication protocol to transmit data (HTML file , Picture file , Query results, etc ).HTTP The protocol works on the client side - The server architecture is top . Browser as HTTP Client pass URL towards HTTP The server is WEB The server sends all requests .Web After the server receives the request , Send response information to client .HTTP The agreement is based on TCP The agreement above .

Transport layer (transport layer) The main task is to provide general data transmission services for the communication between two host processes .TCP It's the transport layer protocol , It mainly solves how to transmit data in the network . Compared with UDP,TCP? What is offered is Connection oriented Of , reliable Data transmission service .

The key is HTTP The use of TCP agreement , And our custom TCP The difference of protocol in message .

http1.1 Agreed TCP The message contains too much information that may be useless during transmission :

HTTP/1.0 200 OK 
Content-Type: text/plain
Content-Length: 137582
Expires: Thu, 05 Dec 1997 16:00:00 GMT
Last-Modified: Wed, 5 August 1996 15:55:28 GMT
Server: Apache 0.84

<html>
  <body>Hello World</body>
</html>



###  Last 

 Do everything with your heart , Pay great attention to details . It looks insignificant 、 If the tedious work is done thoroughly, it will have unexpected value .
 Of course, to become a technical bull, you also need a certain ideological pattern , Thought determines which direction you want to go in the future ,  I suggest reading more books on life planning , Learn more about the ideological pattern of celebrities , In the future, you will go further .

** I've done a collation of more technical point mind maps , It covers the most popular Internet at present 99% Technical points , Here I share this map , And a set of interview system for golden nine and silver ten , Up to collection , Down to distributed microservices **

![](https://s2.51cto.com/images/20210820/1629409639173221.jpg)

![](https://s2.51cto.com/images/20210820/1629409639953983.jpg)

![](https://s2.51cto.com/images/20210820/1629409640784001.jpg)

![](https://s2.51cto.com/images/20210820/1629409640196448.jpg)

 How to obtain this set of high-quality information ?

[**Java Interview selection questions 、 Structure the actual document delivery gate : Get it free of charge here **](https://gitee.com/vip204888/java-p7)
     
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.

copyright notice
author[Programmer's secret place],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2021/08/20210821131859741q.html

Random recommended