Remote Procedure Call (RPC) in Operating Systems
A Remote Procedure Call (RPC) is a communication mechanism used in client-server systems that allows a program to execute a function on another machine as if it were a local function call.
In simple terms, RPC lets one system request a service from another system over a network without worrying about the underlying communication details.
What Does RPC Do?
In an RPC setup, the client sends a request to a server asking it to execute a specific function or procedure. Once the server processes the request, it sends the result back to the client. During this time, the client may either wait for the response or continue execution depending on the type of RPC used.
The key advantage of RPC is that it hides all the complexity of network communication, making remote interactions feel like local function calls. RPC is widely used in distributed systems where different machines need to interact seamlessly.
How RPC Works
Here is a simplified flow of how an RPC operates:
- 1. Client Invocation: The client calls a local function, which is actually handled by the client stub.
- 2. Parameter Packaging (Marshalling): The client stub converts the function parameters into a message format suitable for network transmission.
- 3. Sending Request: The operating system sends this message to the server over the network.
- 4. Server Reception: The server OS receives the message and forwards it to the server stub.
- 5. Parameter Extraction (Unmarshalling): The server stub decodes the message and extracts the parameters.
- 6. Execution: The actual function is executed on the server.
- 7. Response Return: The result is sent back to the client following the same path in reverse.

The execution flow of a Remote Procedure Call
Types of RPC
RPC can be implemented in different ways depending on how communication is handled:
- Synchronous RPC (Blocking): The client sends a request and waits until the server responds. Execution is paused during this time.
- Asynchronous RPC (Non-Blocking): The client sends a request and continues execution. The response is handled later.
- Callback RPC: The server responds by calling back the client. Useful for notifications and real-time updates.
- Batch RPC: Multiple requests are grouped and sent together. Reduces network overhead.
- Broadcast RPC: A single request is sent to multiple servers. Any server can respond if it has the required information.
Components of RPC
- Client: Requests a service from a remote machine.
- Server: Executes the requested function and returns the result.
- Client Stub: Converts function calls into network messages.
- Server Stub: Processes incoming messages and invokes functions.
- RPC Runtime: Manages communication between the client and server.
- Binding: Helps locate the correct server for a request.
Challenges and Solutions
RPC introduces some complications compared to local function calls. Network issues may cause requests to fail or be executed multiple times. Furthermore, the client needs to know how to locate the server (the binding problem). Common solutions to the binding problem include:
- Fixed Binding: Predefined port numbers are used, but this reduces flexibility.
- Dynamic Binding (Rendezvous Mechanism): A central service helps the client discover the correct server dynamically.
Advantages and Limitations
| Advantages of RPC | Limitations of RPC |
|---|---|
| Simplifies distributed communication and hides low-level networking details. | Not a strict standard (different implementations exist across languages/platforms). |
| Reduces development effort as developers interact with remote APIs like local ones. | Limited flexibility across fundamentally different hardware systems. |
| Improves performance by skipping unnecessary networking layers. | Network dependency introduces a risk of latency or connectivity failures. |
RPC vs REST
| Feature | RPC | REST |
|---|---|---|
| Focus | Focuses on executing procedures | Focuses on data operations |
| Interaction | Uses method/function calls | Uses URLs and HTTP methods |
| Protocols | Supports multiple protocols (TCP, HTTP, UDP) | Primarily uses HTTP |
| Usage | Common in internal systems | Widely used in web APIs |
