What is RPC (Remote Procedure Call)?
What is RPC (Remote Procedure Call)?
Remote Procedure Call (RPC) is a protocol that allows a computer program to execute a function or procedure on another computer (remote server) as if it were a local function.
Key Idea: RPC enables communication between different processes across a network or within the same system.
Used In: Microservices, Distributed Systems, API Communication, Cloud Computing.
How Does RPC Work?
Client sends a request โ Calls a function on a remote server.
Server processes the request โ Executes the function.
Server sends a response โ Returns the output to the client.
Example of RPC Flow:
Client App โโ Request (RPC Call) โโ> Remote Server
Remote Server โโ Process & Execute โโ> Send Response
Client App โโ Receive & Process Response โโ> Done
Types of RPC
Synchronous RPC
- Client waits for the server to respond before continuing.
- Example: Traditional API calls (like REST).
Asynchronous RPC
- Client does not wait for a response, allowing parallel execution.
- Example: Event-driven microservices.
RPC vs. REST API
Feature | RPC | REST API |
---|---|---|
Protocol | Can use HTTP, TCP, UDP, gRPC, etc. | Uses HTTP |
Data Format | Binary (Protocol Buffers, Thrift, Avro) or Text (JSON, XML) | JSON/XML |
Performance | Faster (Binary format + Compression) | Slower due to HTTP overhead |
Streaming Support | Yes (gRPC, Thrift, WebSockets) | Limited (Needs WebSockets) |
Use Case | Microservices, High-Performance APIs | Web & Mobile APIs |
Popular RPC Frameworks
RPC Framework | Used For | Protocol |
---|---|---|
gRPC | Microservices, Cloud APIs | HTTP/2 + Protocol Buffers |
Apache Thrift | High-speed RPCs | Binary Protocol, TCP |
JSON-RPC | Web APIs | HTTP + JSON |
XML-RPC | Legacy systems | HTTP + XML |
Example of RPC Call
Using gRPC (Google RPC) in Python:
import grpc
import example_pb2
import example_pb2_grpc
channel = grpc.insecure_channel('localhost:50051')
stub = example_pb2_grpc.GreeterStub(channel)
response = stub.SayHello(example_pb2.HelloRequest(name='Alice'))
print(response.message)
This sends an RPC request to a server and gets a response.
When to Use RPC?
When high-speed communication is needed (Microservices, Cloud).
When APIs must support streaming & multiplexing (gRPC).
When services need to communicate in different programming languages.
What is an RPC Framework?
What is an RPC Framework?
An RPC (Remote Procedure Call) framework is a set of tools, libraries, and protocols that allow applications to execute functions or procedures on a remote server as if they were local functions.
Purpose: Simplifies communication between distributed systems, microservices, and cloud applications.
Example Use Case: A frontend app calling a backend function on a remote server without worrying about networking details.
How Does an RPC Framework Work?
Client makes an RPC request (calls a function remotely).
RPC framework serializes the request (converts data into a transportable format).
Server receives and processes the request.
RPC framework deserializes the response and returns it to the client.
Example of an RPC Call Flow:
Client โโ> RPC Framework โโ> Network โโ> Server
Client <โโ RPC Framework <โโ Network <โโ Server Response
Think of it like calling a function, but it runs on another server!
Popular RPC Frameworks
RPC Framework | Used For | Protocol | Serialization Format |
---|---|---|---|
gRPC | Microservices, Cloud APIs | HTTP/2 | Protocol Buffers (ProtoBuf) |
Apache Thrift | Cross-language RPC | TCP, HTTP | Compact Binary Format |
JSON-RPC | Web APIs, JavaScript-based Apps | HTTP, WebSockets | JSON |
XML-RPC | Legacy Systems | HTTP | XML |
ZeroMQ (รMQ) | High-performance messaging | Custom (No built-in protocol) | Custom |
Dapr | Cloud-Native Applications | HTTP/gRPC | JSON/ProtoBuf |
Why Use an RPC Framework?
Simplicity โ Developers call remote functions like local functions.
High Performance โ Many frameworks (like gRPC) use binary serialization for fast data transmission.
Cross-Language Support โ Works across different programming languages (e.g., Python client calling a Go server).
Streaming Support โ Some frameworks (e.g., gRPC) support bidirectional streaming.
gRPC Example (Python)
Define an RPC Service (hello.proto
):
syntax = "proto3";
service Greeter {
rpc SayHello (HelloRequest) returns (HelloReply);
}
message HelloRequest {
string name = 1;
}
message HelloReply {
string message = 1;
}
The RPC framework handles serialization, networking, and responses automatically!
Final Thoughts
An RPC framework helps build high-performance distributed systems efficiently!
Best for: Microservices, Cloud APIs, and High-Speed Communication.
Best choice: gRPC for modern systems, Thrift for cross-language, and JSON-RPC for web apps.
Difference Between RPC and RPC Framework
Aspect | RPC (Remote Procedure Call) | RPC Framework |
---|---|---|
Definition | A concept that allows calling functions on a remote server as if they were local. | A set of tools, libraries, and protocols that implement RPC functionality. |
Functionality | Enables communication between client and server in distributed systems. | Provides ready-to-use implementations for handling RPC calls, serialization, security, and networking. |
Example Concept | A client requests a function (getUserDetails() ) on a remote server. | A framework like gRPC, Apache Thrift, or JSON-RPC handles the networking, serialization, and execution of getUserDetails() . |
Transport Mechanism | Can work over HTTP, TCP, UDP, WebSockets, etc. | Uses specific transport mechanisms like HTTP/2 (gRPC), TCP (Thrift), or HTTP (JSON-RPC). |
Serialization | Requires a way to encode and decode data (e.g., JSON, XML, Binary). | Built-in serialization formats like ProtoBuf (gRPC), JSON (JSON-RPC), or Binary (Thrift). |
Security | Must be implemented separately (e.g., authentication, encryption). | Many frameworks provide built-in TLS encryption, authentication, and access control. |
Cross-Language Support | Requires manual implementation for different languages. | Provides auto-generated client and server code for multiple languages (e.g., Python, Java, Go, C++). |
How RPC Works (Conceptually)?
Client Calls a Function
- A client program calls a function (
getUserDetails()
) that is actually located on a remote server.
Request Serialization
- The function callโs parameters (data) are converted into a format that can be transmitted over a network (e.g., JSON, Protocol Buffers, XML, Binary).
Network Transmission
- The serialized data is sent over a network (via HTTP, TCP, UDP, WebSockets, etc.).
Server Receives the Request
- The serverโs RPC system deserializes the request and calls the actual function on the server.
Function Execution & Response
- The server executes the function (
getUserDetails()
) and sends the response back to the client.
Client Receives the Response
- The client deserializes the response and continues execution as if the function ran locally.
RPC Conceptual Flow:
pgsqlCopyEditClient โโโ> (Serialize Data) โโโ> Network โโโ> Server
Server โโโ> (Execute Function) โโโ> Return Response โโโ> Client
RPC vs. Normal Function Calls
Feature | Local Function Call | Remote Procedure Call (RPC) |
---|---|---|
Execution Location | Runs on the same machine | Runs on a remote server |
Data Passing | Direct memory access | Data is serialized and sent over the network |
Performance | Fast (no network delay) | Slower (network latency) |
Complexity | Simple | Requires handling network failures, serialization, security |
Use Case | Local programs | Microservices, Cloud APIs, Distributed Systems |
Real-World Use Cases of RPC
Microservices Communication โ Services talk to each other in cloud-native applications.
Database Requests โ Clients call database functions remotely.
Remote System Administration โ Commands are executed on remote servers.
Game Servers & Multiplayer Apps โ Actions from one player affect other players over a network.
List of All Popular RPC Frameworks
RPC frameworks simplify remote function execution by handling networking, serialization, and security. Below is a list of widely used RPC frameworks categorized based on their use cases.
Modern High-Performance RPC Frameworks
Framework | Description | Protocol | Serialization Format | Best For |
---|---|---|---|---|
gRPC | Googleโs high-performance RPC framework | HTTP/2 | Protocol Buffers (ProtoBuf) | Microservices, Cloud APIs |
Apache Thrift | Cross-language RPC system | TCP, HTTP | Compact Binary, JSON, Simple JSON | Large-scale distributed systems |
Capโn Proto | High-speed serialization and RPC | Custom (No extra encoding needed) | Capโn Proto (Zero Parsing Overhead) | Low-latency systems |
Dapr | Cloud-native distributed application runtime | HTTP, gRPC | JSON, ProtoBuf | Microservices & Kubernetes |
Web-Based RPC Frameworks
Framework | Description | Protocol | Serialization Format | Best For |
---|---|---|---|---|
JSON-RPC | Lightweight RPC using JSON over HTTP/WebSockets | HTTP, WebSockets | JSON | Web applications, JavaScript-based systems |
XML-RPC | Simple RPC protocol using XML over HTTP | HTTP | XML | Legacy systems |
WAMP (Web Application Messaging Protocol) | Web-based RPC with real-time pub/sub | WebSockets, TCP | JSON, MsgPack, CBOR | WebSockets-based APIs |
Falcor | Netflixโs RPC for efficient data fetching | HTTP | JSON | Web applications |
Messaging-Based RPC Frameworks
Framework | Description | Protocol | Serialization Format | Best For |
---|---|---|---|---|
ZeroMQ (รMQ) | High-performance messaging library | TCP, IPC, Multicast | Custom | Low-latency, real-time systems |
Apache Avro | Schema-based RPC with a focus on Big Data | TCP, HTTP | Avro Binary, JSON | Big Data, Streaming (Kafka, Hadoop) |
MessagePack-RPC | Lightweight binary-based RPC | TCP, UDP | MessagePack | IoT & high-performance applications |
Nanomsg | Simplified version of ZeroMQ | TCP, IPC | Custom | High-speed messaging |
Enterprise & Legacy RPC Frameworks
Framework | Description | Protocol | Serialization Format | Best For |
---|---|---|---|---|
CORBA (Common Object Request Broker Architecture) | Classic RPC framework for enterprise systems | IIOP (TCP-based) | Binary (IDL-based) | Legacy enterprise applications |
RMI (Remote Method Invocation) | Javaโs built-in RPC mechanism | JRMP (Java Remote Method Protocol) | Java Serialization | Java-based distributed applications |
Hessian | Lightweight binary-based RPC | HTTP | Hessian Binary Format | Java & cross-platform systems |
TARS | Tencentโs distributed RPC framework | TCP, HTTP | TARS, ProtoBuf, JSON | Large-scale microservices |
Blockchain & Decentralized RPC Frameworks
Framework | Description | Protocol | Serialization Format | Best For |
---|---|---|---|---|
Ethereum JSON-RPC | RPC API for Ethereum blockchain | HTTP, WebSockets | JSON | Blockchain applications |
Bitcoin RPC | RPC interface for Bitcoin nodes | HTTP | JSON | Cryptocurrency development |
Choosing the Right RPC Framework
Use Case | Recommended Framework |
---|---|
Microservices & Cloud | gRPC, Thrift, Dapr |
Web-Based RPC | JSON-RPC, WAMP, Falcor |
Big Data & Streaming | Apache Avro, MessagePack-RPC |
Low-Latency & High-Performance | ZeroMQ, Capโn Proto |
Enterprise & Legacy Apps | CORBA, RMI, Hessian |
Blockchain Apps | Ethereum JSON-RPC, Bitcoin RPC |
Final Thoughts
If you need a high-performance modern RPC framework, use gRPC or Apache Thrift.
For web-based applications, JSON-RPC is a lightweight option.
For low-latency, high-speed messaging, ZeroMQ or Capโn Proto are great choices.
For distributed systems and big data, Apache Avro is recommended.
Default RPC Methods in Different Scenarios
Below is a breakdown of what happens by default when you call a remote function in different environments.
Scenario | What Happens By Default? | Default RPC Framework |
---|---|---|
PHP in XAMPP (Apache Server) | No native RPC; you must use JSON-RPC, SOAP, or REST | |
Java Calling Remote Functions | Uses Java RMI (Remote Method Invocation) | |
Python Calling a Remote Function | Uses built-in xmlrpc.client for XML-RPC | |
Node.js Communicating with Remote Services | Typically uses HTTP API calls (REST) | |
.NET / C# Calling Remote Services | Uses WCF (Windows Communication Foundation) | |
C++ Distributed Systems | Uses CORBA (Common Object Request Broker Architecture) | |
Web Browsers Calling Remote Functions | Uses AJAX (JavaScript HTTP Requests) | |
Linux System Calls | Uses gRPC or DBus for inter-process communication | |
Blockchain Smart Contracts (Ethereum, Bitcoin, etc.) | Uses JSON-RPC to communicate with nodes |
Iโm a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I am working at Cotocus. I blog tech insights at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at I reviewed , and SEO strategies at Wizbrand.
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at PINTEREST
Rajesh Kumar at QUORA
Rajesh Kumar at WIZBRAND