Skip to content

Instantly share code, notes, and snippets.

@qcam
Last active August 30, 2016 00:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qcam/337ad23f5f8e75868c427f2f52db7c21 to your computer and use it in GitHub Desktop.
Save qcam/337ad23f5f8e75868c427f2f52db7c21 to your computer and use it in GitHub Desktop.
[HARDCORE] RPC.md

What's RPC?

In distributed computing, a remote procedure call (RPC) is when a computer program causes a procedure (this is what it differs from REST) to execute in another address space (commonly on another computer on a shared network), which is coded as if it were a normal (local) procedure call, without the programmer explicitly coding the details for the remote interaction.

There are multiple implementation of RPC: ONC RPC, JSON-RPC, XML-RPC, gRPC, SOAP, etc.

How RPC works?

  1. The client calls the client stub. The call is a local procedure call, with parameters pushed on to the stack in the normal way.
  2. The client stub packs the parameters into a message and makes a system call to send the message. Packing the parameters is called marshalling.
  3. The client's local operating system sends the message from the client machine to the server machine.
  4. The local operating system on the server machine passes the incoming packets to the server stub.
  5. The server stub unpacks the parameters from the message. Unpacking the parameters is called unmarshalling.
  6. Finally, the server stub calls the server procedure. The reply traces the same steps in the reverse direction.

RPC Transport and Semantics

  • The RPC protocol can be implemented on several different transport protocols.
  • The RPC protocol does not care how a message is passed, but only with specification and interpretation of messages.
  • The client and server must agree on their transport protocol choices.
  • RPC does not try to implement any kind of reliability and that the application may need to be aware of the type of transport protocol underneath RPC.
  • Because of transport independence, the RPC protocol does not attach specific semantics to the remote procedures or their execution requirements. Semantics can be inferred from (but should be explicitly specified by) the underlying transport protocol.

References

  1. RFC 1057 - RPC: Remote Procedure Call Protocol Specification Version 1 https://tools.ietf.org/html/rfc1057
  2. RFC 5531 - RPC: Remote Procedure Call Protocol Specification Version 2 https://tools.ietf.org/html/rfc5531
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment