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?
1๏ธโฃ Client sends a request โ Calls a function on a remote server.
2๏ธโฃ Server processes the request โ Executes the function.
3๏ธโฃ 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
1๏ธโฃ Synchronous RPC
- Client waits for the server to respond before continuing.
- Example: Traditional API calls (like REST).
2๏ธโฃ 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)
Code language: JavaScript (javascript)
โ 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?
1๏ธโฃ Client makes an RPC request (calls a function remotely).
2๏ธโฃ RPC framework serializes the request (converts data into a transportable format).
3๏ธโฃ Server receives and processes the request.
4๏ธโฃ 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;
}
Code language: JavaScript (javascript)
โ 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)?
1๏ธโฃ Client Calls a Function
- A client program calls a function (
getUserDetails()) that is actually located on a remote server.
2๏ธโฃ 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).
3๏ธโฃ Network Transmission
- The serialized data is sent over a network (via HTTP, TCP, UDP, WebSockets, etc.).
4๏ธโฃ Server Receives the Request
- The server’s RPC system deserializes the request and calls the actual function on the server.
5๏ธโฃ Function Execution & Response
- The server executes the function (
getUserDetails()) and sends the response back to the client.
6๏ธโฃ 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.
1๏ธโฃ 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 |
2๏ธโฃ 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 |
3๏ธโฃ 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 |
4๏ธโฃ 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 |
5๏ธโฃ 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 | โ None (you must specify) |
| Java Calling Remote Functions | Uses Java RMI (Remote Method Invocation) | โ Java RMI |
| Python Calling a Remote Function | Uses built-in xmlrpc.client for XML-RPC | โ XML-RPC |
| Node.js Communicating with Remote Services | Typically uses HTTP API calls (REST) | โ HTTP (REST) |
| .NET / C# Calling Remote Services | Uses WCF (Windows Communication Foundation) | โ WCF (SOAP/XML-RPC) |
| C++ Distributed Systems | Uses CORBA (Common Object Request Broker Architecture) | โ CORBA |
| Web Browsers Calling Remote Functions | Uses AJAX (JavaScript HTTP Requests) | โ REST over HTTP (AJAX, Fetch API) |
| Linux System Calls | Uses gRPC or DBus for inter-process communication | โ gRPC, DBus |
| Blockchain Smart Contracts (Ethereum, Bitcoin, etc.) | Uses JSON-RPC to communicate with nodes | โ JSON-RPC |
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services โ all in one place.
Explore Hospitals