RPC Principle Detailed

Source: Internet
Author: User

Transferred from: http://www.open-open.com/lib/view/open1425797146897.html

RPC feature target

The primary function of RPC is to make it easier to build distributed computing (applications), without losing the semantic simplicity of local calls when providing powerful remote invocation capabilities.

To achieve this goal, the RPC framework needs to provide a transparent calling mechanism so that the consumer does not have to explicitly differentiate between local calls and remote calls

RPC Call Classification:

RPC calls can be divided into two types:

1) Synchronous invocation: Client waits for call execution to complete and returns execution result

2) Asynchronous invocation: Client calls do not wait for the execution result to return, but can still get execution result by callback method

RPC Fabric Disassembly

RPC provider through the Rpcserver export (exported) remote interface method, RPC client side via Rpcclient import (imported) Remote interface method

Client side:

Call the remote interface method like the local method, the RPC framework implements the proxy implementation of the interface, and the actual invocation is delegated to the proxy rpcproxy

The proxy prcproxy encapsulates the call information and transfers the call to Prcinvoker to actually execute

The client's rpcinvoker through the connector Rpcconnector maintains the channel Rpcchannel with the server, uses Prcprotocol to execute the protocol encoding, and sends the encoded request message through the channel to the Service party

Service party:

Accepts the client's call request through the receiver Rpcacceptor, and also uses RpcProtocol to perform the protocol decoding

The decoded call message is passed to the Rpcprocessor to control the processing of the call procedure

Finally delegate to Prcinvoker to actually execute the call and put back the execution result

Responsibility planning for each component:

      1. Rpcserver
        Responsible for exporting the Remote Interface (export)
      2. Rpcclient
        The proxy implementation that is responsible for importing (import) the remote interface
      3. RpcProxy
        Proxy implementations of remote interfaces
      4. Rpcinvoker
        Client-side implementation: Responsible for encoding call information and sending call requests to the service party and waiting for the call result to return
        Service-Side implementation: Responsible for invoking the specific implementation of the server-side interface and returning the result of the call
      5. RpcProtocol
        Responsible for protocol compilation/decoding
      6. Rpcconnector
        Responsible for maintaining the connection channel between the client and the service party and sending the data to the service party
      7. Rpcacceptor
        Responsible for receiving client requests and returning request results
      8. Rpcprocessor
        Responsible for controlling the call process in the service side, including managing the call thread pool, time-out, etc.
      9. Rpcchannel
        Data transmission Channel

(go) RPC principle detailed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.