Interview question 2: What is the difference between HTTP and RPC?

Interview question two

What is the difference between HTTP and RPC?

Ask Scope: Distributed and Microservices

Difficulty index: 4 stars

Inspection frequency: 70-80%

Development period: about 3 years

Answer this question from three aspects:

1. Functional characteristics

1) HTTP is a protocol belonging to the application layer: Hypertext Transfer Protocol, which is the basis of the WWW World Wide Web and mainly serves data transmission between the web page and the server.

2) RPC is a remote procedure call protocol. It is positioned to realize data communication between different computers, shield the complexity of the underlying communication protocol, and allow developers to complete remote service calls just like using local methods (services).

2. Implementation principle

1) HTTP is a mature application layer protocol that defines the communication message format.

Method: post get

URI: /form/entry

Protocol version: http 1.1

Request Header: Request Header

Response header: Response Header

Request body: Request body

Response body: Response body

2) RPC is a protocol specification and has no specific implementation; only the communication framework completed in accordance with the RPC protocol is the RPC framework, dubbo framework, and the bottom layer is the RPC protocol. RPC is used for calls between various services, which will be faster and more efficient.

3) From the application level

The frameworks of HTTP and RPC protocols can both realize communication between services across network nodes. They have something in common, the bottom layer is the TCP protocol. RPC: Annotation protocol, conforms to the RPC protocol and belongs to the RPC framework. The network communication layer of RPC can be implemented through the http protocol, such as the underlying layer of OpenFeign, HTTP.

Comments:

The summary of the answer starts with the concept, which is general and easy to explain; the implementation principle and the application level.

think:

Dubbo framework

OpenFeign service callInsert image description here

Guess you like

Origin blog.csdn.net/zhangchen124/article/details/135231394