Comparison and analysis of RPC and REST

What is the RPC

From wiki:

In distributed computing, remote procedure call is a computer communication protocol. This protocol allows a program running on one computer to call a subroutine in another address space without the programmer having to program for this interaction as if it were a local program. RPC is a server – client mode. The classical implementation is a system of sending request – receiving response for information exchange.

Remote Procedure Call (RPC) is to solve the problem of data interaction between different (system) services in distributed system. It was proposed by Nelson in 1981, aiming at “calling Remote methods like calling local methods”.

The core of

The RPC core process is shown below

  • Local invocation: Normal business logic, used no differently than local methods

  • Local proxy stubs: get what methods and arguments are called locally (remotely)

  • Local serialization Deserialization: Serialization of the data received above and deserialization when the data is returned remotely

  • Network communication: Socket communication, usually TCP

  • Remote deserialization and serialization: the result of the communication is deserialized to the next process, and the next process returns the result and serializes it to the network

  • Remote service stub: After receiving the serialized results, find the service map and forward it to the specific service for processing

  • Invoke the actual business service: The actual business interface implementation

Usage scenarios

The emphasis on performance transfer is expected to be used as a native method between different services within the same system, such as today’s microservices architecture systems

What is the REST

From wiki:

Presentation layer state transition is a web software architecture style proposed by Dr. Roy Thomas Fielding in his doctoral thesis in 2000. The purpose is to facilitate the communication between different software/programs on the network. Presentation layer state transition is a set of constraints and attributes based on hypertext Transfer protocol. It is a software construction style designed to provide universal network services.

Representational State Transfer (Rest) is an architectural style that controls access to service resources by imposing a specific set of constraints on an interface.

The core of

The Rest process looks like this:

Resources: Specific information on the network, can be a piece of text, a picture, a service, etc., in short, a specific entity. It can be pointed to by a URI and accessed by accessing its URI, which is the identifier of each resource.

Presentation layer: the specific presentation form of resources, known as the presentation layer, such as text can be presented in TXT format, HTML format, XML format and so on.

State transition: If the client wants to operate the server, it must somehow make the server “state transition”. And this transformation is built on top of the presentation layer, so it is “presentation layer state transformation”. The HTTP protocol defines GET, POST, PUT, DELETE, and so on

Summarize its characteristics

  • Each URI represents a resource;

  • Some representation layer that passes this resource between the client and the server;

  • The client uses four HTTP verbs to perform operations on server-side resources to achieve “presentation layer state transformation”.

Usage scenarios

External exposure interface services, but the need to strictly control the type of request and information format, suitable for website external services

RPC versus REST

  1. RPC uses client/ Server mode, while REST tends to browser/ Server
  2. RPC is based on TCP and REST is based on HTTP
  3. Based on the protocol used, RPC is more efficient because it carries less information and is closer to network transmission
  4. REST expressions are more readable depending on the protocol used
  5. REST is more binding and THERE is no uniform standard for RPC
  6. RPC is flexible and closer to the bottom, so it can implement REST

reference

Debunking the Myths of RPC & REST

Remote procedure call

The difference between task queues and message queues, RPC

Understanding RESTful Architecture

Remote Procedure Call (RPC)

The difference and relation between HTTP and RPC