Remote Procedure Call (RPC)

What is Remote Procedure Call (RPC)?

Remote Procedure Call is a software communication protocol that one program can use to request a service from a program located in another computer on a network without having to understand the network’s details. RPC is used to call other processes on the remote systems like a local system. A procedure call is also sometimes known as a function call or a subroutine call.

What does RPC do?

When program statements that use the RPC framework are compiled into an executable program, a stub is included in the compiled code that acts as the representative of the remote procedure code. When the program is run and the procedure call is issued, the stub receives the request and forwards it to a client runtime program in the local computer. The first time the client stub is invoked, it contacts a name server to determine the transport address where the server resides.

How does RPC work?

When a remote procedure call is invoked, the calling environment is suspended, the procedure parameters are transferred across the network to the environment where the procedure is to execute, and the procedure is then executed in that environment.

  1. The client stub packs the procedure parameters into a message and makes a system call to send the message. The packing of the procedure parameters is called marshaling.
  2. The client’s local OS sends the message from the client machine to the remote server machine.
  3. The server OS passes the incoming packets to the server stub.
  4. The server stub unpacks the parameters — called unmarshalling — from the message.
  5. When the server procedure is finished, it returns to the server stub, which marshals the return values into a message. The server stub then hands the message to the transport layer.
  6. The transport layer sends the resulting message back to the client transport layer, which hands the message back to the client stub.
  7. The client stub unmarshalls the return parameters and execution returns to the caller.

Types of RPC

There are several RPC models and distributed computing implementations. A popular model and implementation are the Open Software Foundation’s (OSF) Distributed Computing Environment (DCE). The Institute of Electrical and Electronics Engineers (IEEE) defines RPC in its ISO Remote Procedure Call Specification, ISO/IEC CD 11578 N6561, ISO/IEC, November 1991.

  • The client makes a call and continues with their own processing. The server doesn’t reply.
  • A facility for sending several client non-blocking calls in one batch.
  • RPC clients have a broadcast facility, i.e., they can send messages to many servers and then receive all the resulting replies.
  • The client makes a nonblocking client/server call; the server signals the call is completed by calling a procedure associated with the client.

Pros and cons of RPC

Though it boasts a wide range of benefits, there is certainly a share of pitfalls that those who use RPC should be aware of.

  • Can be used in a distributed environment, as well as the local environment.
  • Supports process-oriented and thread-oriented models.
  • Hides the internal message-passing mechanism from the user.
  • Requires only minimal effort to rewrite and redevelop the code.
  • Provides abstraction, i.e., the message-passing nature of network communication is hidden from the user.
  • Omits many of the protocol layers to improve performance.
  • RPC is highly vulnerable to failure because it involves a communication system, another machine, and another process.
  • There is no uniform standard for RPC; it can be implemented in a variety of ways.
  • RPC is only interaction-based, and as such, it doesn’t offer any flexibility when it comes to hardware architecture.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store