Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the structure of RPC?

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "what is the structure of RPC". In daily operation, I believe many people have doubts about how the structure of RPC is. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts about "what is the structure of RPC?" Next, please follow the editor to study!

What is RPC?

The full name of RPC is Remote Procedure Call, which is a way of interprocess communication. It allows a program to call a procedure or function in another address space (usually on another machine that shares the network) without the programmer explicitly coding the details of the remote call. That is, programmers write basically the same calling code, whether it is local or remote.

Rpc structure

The conceptual term RPC was proposed by Bruce Jay Nelson in the 1980s, referring to his paper Implementing Remote Procedure Calls.

Nelson's paper points out that the program to implement RPC consists of five parts:

UserUser-stubRPCRuntimeServer-stubServer

The relationship between these five parts is shown in the following figure

Here user is the client side, and when user wants to make a remote call, it actually calls user-stub locally. User-stub is responsible for encoding the called interfaces, methods, and parameters through the agreed protocol specification and transferring them to the remote instance through the local RPCRuntime instance. After receiving the request, the remote RPCRuntime instance sends it to server-stub for decoding and initiates a local call, and the call result is returned to the user.

RPC call classification

There are two types of RPC calls:

Synchronous call: the client waits for the call to complete and returns the result. Asynchronous call: the client does not have to wait for the execution result to return after the call, but the returned result can still be obtained through callback notification and other methods. If the client does not care about the result returned by the call, it becomes an one-way asynchronous call, and the one-way call does not return the result.

The difference between async and synchronization lies in whether to wait for the server to complete execution and return the result.

RPC structure disassembly

The detailed components of rpc are as follows:

The RPC server exports (export) the remote interface method through RpcServer, while the client introduces (import) the remote interface method through RpcClient. The client invokes the remote interface method like a local method, the RPC framework provides a proxy implementation of the interface, and the actual call is delegated to the proxy RpcProxy. The agent encapsulates the call information and transfers the call to RpcInvoker for actual execution. The RpcInvoker on the client maintains the channel RpcChannel with the server through the connector RpcConnector, and uses RpcProtocol to perform protocol coding (encode) and sends the encoded request message to the server through the channel.

The RPC server receiver RpcAcceptor receives the call request from the client and also uses RpcProtocol to perform protocol decoding (decode). The decoded call information is passed to RpcProcessor to control the call process, and then delegated to RpcInvoker to actually execute and return the call result.

RPC component responsibility

The responsibilities of each component are as follows:

RpcServer: responsible for exporting (export) remote interface RpcClient: responsible for importing (import) remote interface proxy implementation RpcProxy: remote interface proxy implementation RpcInvoker: client implementation: responsible for encoding call information and sending call requests to the server and waiting for the call result to return Server implementation: responsible for calling the specific implementation of the server interface and returning the call result RpcProtocol: responsible for protocol encoding / decoding RpcConnector: responsible for maintaining the connection channel between the client and the server and sending data to the server RpcAcceptor: responsible for receiving the client request and returning the request result RpcProcessor: responsible for controlling the calling process at the server side, including managing the calling thread pool, timeout, etc. RpcChannel: data transmission channel to this The study on "what is the structure of RPC" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report