Tags:conceptRPCRemoteProcedureCalls Status:🟩
Remote Procedure Calls (RPC)
Summary
Remote Procedure Calls (RPC) provide a mechanism for executing procedures on remote systems, making network communication simpler and more abstracted for developers. By enabling seamless function calls across networked systems, RPC plays a crucial role in distributed computing.
Details
What is RPC?
Definition: RPC is a protocol that allows a program to execute a procedure on another computer (or address space) as if it were executing locally. This abstraction helps developers avoid dealing with the complexities of network communication directly.

Old Methods: RMI, CORBA, SOAP/WS*
- RMI (Remote Method Invocation): A Java-specific method that allows Java objects to invoke methods on other objects over a network.
- CORBA (Common Object Request Broker Architecture): A standard designed to enable communication between various software components regardless of their location or the programming languages used.
- SOAP (Simple Object Access Protocol): An XML-based protocol for exchanging structured information in web services, typically over HTTP. It is often seen as complex and heavyweight due to its reliance on XML.
Modern Methods: RESTful and gRPC
- RESTful APIs: Use HTTP for communication and often employ JSON for data interchange, making them lightweight and easier to work with than SOAP. Stateless interactions, each request is self-contained.
- gRPC: A modern framework that uses HTTP/2 for transport, allowing for faster binary communication. It supports synchronous and asynchronous calls, can handle streaming data, and employs Protocol Buffers for message serialization. Additionally, it accommodates multiple types of communication, including Unary, Server/Client Streaming, and Bidirectional.

Challenges with RPC
- Request-Reply Semantics: Handling issues like:
- Omission Failures: Situations where requests or replies are lost.
- Out-of-Order Messages: Messages that arrive in a different sequence than sent, which can complicate processing.
- Semantic Variants:
- Maybe Semantics: The operation might succeed, but there’s a chance it could fail (uncertain outcome).
- At-least-once Semantics: Guarantees that the operation will be executed at least one time, but could be executed multiple times, possibly leading to duplicate actions.
- At-most-once Semantics: Ensures that the operation will be executed no more than once, preventing duplicates but risking failure.
Examples
- Weather Service (RESTful): A client requests the current weather data from an API (e.g.,
https://api.open-meteo.com/v1/forecast?latitude=55&longitude=12). - Payment System (gRPC): A system calls a remote service to process payment details using gRPC, passing serialized payment information and receiving confirmation back.
HTTP Example
