Remote procedure call
In computer science, a remote procedure call (RPC) is an inter-process communication that allows a computer program to cause a subroutine or procedure to execute in another address space (commonly on another computer on a shared network) without the programmer explicitly coding the details for this remote interaction. That is, the programmer writes essentially the same code whether the subroutine is local to the executing program, or remote. When the software in question uses object-oriented principles, RPC is called remote invocation or remote method invocation.
Note that there are many different (often incompatible) technologies commonly used to accomplish this.
Internet protocol suite |
---|
Application layer |
Transport layer |
Internet layer |
Link layer |
History and origins
The idea of RPC (Remote Procedure Call) goes back at least as far as 1976, when it was described in RFC 707. One of the first business uses of RPC was by Xerox under the name "Courier" in 1981. The first popular implementation of RPC on Unix was Sun's RPC (now called ONC RPC), used as the basis for Network File System.
Message passing
An RPC is initiated by the client, which sends a request message to a known remote server to execute a specified procedure with supplied parameters. The remote server sends a response to the client, and the application continues its process. There are many variations and subtleties in various implementations, resulting in a variety of different (incompatible) RPC protocols. While the server is processing the call, the client is blocked (it waits until the server has finished processing before resuming execution).
An important difference between remote procedure calls and local calls is that remote calls can fail because of unpredictable network problems. Also, callers generally must deal with such failures without knowing whether the remote procedure was actually invoked. Idempotent procedures (those that have no additional effects if called more than once) are easily handled, but enough difficulties remain that code to call remote procedures is often confined to carefully written low-level subsystems.
Sequence of events during a RPC
- The client calls the Client stub. The call is a local procedure call, with parameters pushed on to the stack in the normal way.
- The client stub packs the parameters into a message and makes a system call to send the message. Packing the parameters is called marshalling.
- The kernel sends the message from the client machine to the server machine.
- The kernel passes the incoming packets to the server stub.
- Finally, the server stub calls the server procedure. The reply traces the same steps in the reverse direction.
Standard contact mechanisms
To let different clients access servers, a number of standardized RPC systems have been created. Most of these use an interface description language (IDL) to let various platforms call the RPC. The IDL files can then be used to generate code to interface between the client and server. The most common tool used for this is RPCGEN.
Other RPC analogues
RPC analogues found elsewhere:
- Java's Java Remote Method Invocation (Java RMI) API provides similar functionality to standard UNIX RPC methods.
- Modula-3's Network Objects, which were the basis for Java's RMI[1]
- XML-RPC is an RPC protocol that uses XML to encode its calls and HTTP as a transport mechanism.
- JSON-RPC is an RPC protocol that uses JSON encoded messages
- SOAP is a successor of XML-RPC and also uses XML to encode its HTTP-based calls.
- Microsoft .NET Remoting offers RPC facilities for distributed systems implemented on the Windows platform.
- RPyC implements RPC mechanisms in Python, with support for asynchronous calls.
- Pyro Object Oriented form of RPC for Python.
- Etch (protocol) framework for building network services.
- Facebook's Thrift protocol and framework.
- CORBA provides remote procedure invocation through an intermediate layer called the "Object Request Broker"
- DRb allows Ruby programs to communicate with each other on the same machine or over a network. DRb uses remote method invocation (RMI) to pass commands and data between processes.
- AMF allows Flex applications to communicate with back-ends or other applications that support AMF.
- Libevent provides a framework for creating RPC servers and clients.[2]
- Windows Communication Foundation is an application programming interface in the .NET Framework for building connected, service-oriented applications.
Web
See also
- Local Procedure Call
- SOAP
- HTTP
- ODBC
- Remote function call
- External Data Representation
- ROA (Resource-oriented architecture)
References
Bruce Jay Nelson, Remote Procedure Call, PARC CSL-81-9 (Also CMU-CS-81-119), Xerox Palo Alto Research Center, Palo Alto, CA 94306, May 1981, other keywords: IPC, interprocess communication, Emissary, RPC, PhD thesis.
External links
- RFC 1057 - Specifies version 1 of ONC RPC
- RFC 5531 - Specifies version 2 of ONC RPC
- Remote Procedure Calls (RPC) — A tutorial on ONC RPC by Dr Dave Marshall of Cardiff University
- Introduction to RPC Programming — A developer's introduction to RPC and XDR, from SGI IRIX documentation.
This article is based on material taken from the Free On-line Dictionary of Computing prior to 1 November 2008 and incorporated under the "relicensing" terms of the GFDL, version 1.3 or later.