0%

Talking About Node RPC


What Is Serialization

Data transmitted over a TCP channel can only be in binary form. So converting a data structure or an object into binary form is called serialization. The reverse process is called deserialization. The rules that define how they convert back and forth are called a protocol.


What Is RPC

RPC stands for Remote Procedure Call. Most RPC systems are based on TCP. The general implementation flow is as follows:

  1. The frontend calls the corresponding interface through a Proxy. The Proxy converts information such as the RPC service name, method name, and parameters into an RPC Request object and passes it to the RPC framework.
  2. The RPC framework serializes the RPC Request object into binary form according to the RPC protocol.
  3. The RPC framework sends the binary data to the backend through a TCP channel.
  4. The backend deserializes the binary data back into an RPC Request object.
  5. The backend maps the deserialized data to the actual method it implements, passes in the parameters, obtains the result, and then packages it into an RPC Response object for the RPC framework.
  6. The RPC framework serializes the RPC Response object into binary form according to the RPC protocol and sends it back to the frontend through the TCP channel.
  7. After receiving the binary data, the frontend deserializes it into an RPC Response object, and the Proxy returns the result to the business code.
-------------本文结束感谢您的阅读-------------