{"id":48535,"date":"2025-02-18T08:29:44","date_gmt":"2025-02-18T08:29:44","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=48535"},"modified":"2025-02-18T08:29:44","modified_gmt":"2025-02-18T08:29:44","slug":"a-complete-guide-of-rpc-remote-procedure-call","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/a-complete-guide-of-rpc-remote-procedure-call\/","title":{"rendered":"A Complete Guide of RPC (Remote Procedure Call)"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">What is RPC (Remote Procedure Call)?<\/h2>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\ud83d\udd39 What is RPC (Remote Procedure Call)?<\/strong><\/h2>\n\n\n\n<p><strong>Remote Procedure Call (RPC)<\/strong> is a <strong>protocol<\/strong> that allows a <strong>computer program to execute a function or procedure on another computer (remote server) as if it were a local function<\/strong>.<\/p>\n\n\n\n<p>\u2705 <strong>Key Idea<\/strong>: RPC enables communication between different processes across a <strong>network or within the same system<\/strong>.<br>\u2705 <strong>Used In<\/strong>: Microservices, Distributed Systems, API Communication, Cloud Computing.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\ud83d\udd39 How Does RPC Work?<\/strong><\/h2>\n\n\n\n<p>1\ufe0f\u20e3 <strong>Client sends a request<\/strong> \u2192 Calls a function on a remote server.<br>2\ufe0f\u20e3 <strong>Server processes the request<\/strong> \u2192 Executes the function.<br>3\ufe0f\u20e3 <strong>Server sends a response<\/strong> \u2192 Returns the output to the client.<\/p>\n\n\n\n<p>\ud83d\udccc <strong>Example of RPC Flow<\/strong>:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">Client App  \u2500\u2500 Request (RPC Call) \u2500\u2500&gt; Remote Server  \nRemote Server  \u2500\u2500 Process &amp; Execute \u2500\u2500&gt; Send Response  \nClient App  \u2500\u2500 Receive &amp; Process Response \u2500\u2500&gt; Done \u2705\n<\/code><\/span><\/pre>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\ud83d\udd39 Types of RPC<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1\ufe0f\u20e3 Synchronous RPC<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Client <strong>waits<\/strong> for the server to respond before continuing.<\/li>\n\n\n\n<li><strong>Example<\/strong>: Traditional API calls (like REST).<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2\ufe0f\u20e3 Asynchronous RPC<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Client <strong>does not wait<\/strong> for a response, allowing parallel execution.<\/li>\n\n\n\n<li><strong>Example<\/strong>: Event-driven microservices.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\ud83d\udd39 RPC vs. REST API<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Feature<\/th><th>RPC<\/th><th>REST API<\/th><\/tr><\/thead><tbody><tr><td><strong>Protocol<\/strong><\/td><td>Can use <strong>HTTP, TCP, UDP, gRPC, etc.<\/strong><\/td><td>Uses <strong>HTTP<\/strong><\/td><\/tr><tr><td><strong>Data Format<\/strong><\/td><td><strong>Binary (Protocol Buffers, Thrift, Avro)<\/strong> or <strong>Text (JSON, XML)<\/strong><\/td><td><strong>JSON\/XML<\/strong><\/td><\/tr><tr><td><strong>Performance<\/strong><\/td><td><strong>Faster (Binary format + Compression)<\/strong><\/td><td>Slower due to <strong>HTTP overhead<\/strong><\/td><\/tr><tr><td><strong>Streaming Support<\/strong><\/td><td><strong>Yes (gRPC, Thrift, WebSockets)<\/strong><\/td><td><strong>Limited (Needs WebSockets)<\/strong><\/td><\/tr><tr><td><strong>Use Case<\/strong><\/td><td><strong>Microservices, High-Performance APIs<\/strong><\/td><td><strong>Web &amp; Mobile APIs<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\ud83d\udd39 Popular RPC Frameworks<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><strong>RPC Framework<\/strong><\/th><th><strong>Used For<\/strong><\/th><th><strong>Protocol<\/strong><\/th><\/tr><\/thead><tbody><tr><td><strong>gRPC<\/strong><\/td><td>Microservices, Cloud APIs<\/td><td><strong>HTTP\/2 + Protocol Buffers<\/strong><\/td><\/tr><tr><td><strong>Apache Thrift<\/strong><\/td><td>High-speed RPCs<\/td><td><strong>Binary Protocol, TCP<\/strong><\/td><\/tr><tr><td><strong>JSON-RPC<\/strong><\/td><td>Web APIs<\/td><td><strong>HTTP + JSON<\/strong><\/td><\/tr><tr><td><strong>XML-RPC<\/strong><\/td><td>Legacy systems<\/td><td><strong>HTTP + XML<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\ud83d\udd39 Example of RPC Call<\/strong><\/h2>\n\n\n\n<p><strong>Using gRPC (Google RPC) in Python:<\/strong><\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">import<\/span> grpc\n<span class=\"hljs-keyword\">import<\/span> example_pb2\n<span class=\"hljs-keyword\">import<\/span> example_pb2_grpc\n\nchannel = grpc.insecure_channel(<span class=\"hljs-string\">'localhost:50051'<\/span>)\nstub = example_pb2_grpc.GreeterStub(channel)\nresponse = stub.SayHello(example_pb2.HelloRequest(name=<span class=\"hljs-string\">'Alice'<\/span>))\nprint(response.message)\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>\u2705 <strong>This sends an RPC request<\/strong> to a server and gets a response.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\ud83c\udfaf When to Use RPC?<\/strong><\/h2>\n\n\n\n<p>\u2705 When <strong>high-speed communication<\/strong> is needed (Microservices, Cloud).<br>\u2705 When APIs <strong>must support streaming &amp; multiplexing<\/strong> (gRPC).<br>\u2705 When services <strong>need to communicate in different programming languages<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What is an RPC Framework?<\/h2>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\ud83d\udd39 What is an RPC Framework?<\/strong><\/h2>\n\n\n\n<p>An <strong>RPC (Remote Procedure Call) framework<\/strong> is a <strong>set of tools, libraries, and protocols<\/strong> that allow applications to <strong>execute functions or procedures on a remote server as if they were local functions<\/strong>.<\/p>\n\n\n\n<p>\u2705 <strong>Purpose:<\/strong> Simplifies communication between distributed systems, microservices, and cloud applications.<br>\u2705 <strong>Example Use Case:<\/strong> A frontend app calling a backend function on a remote server without worrying about networking details.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\ud83d\udd39 How Does an RPC Framework Work?<\/strong><\/h2>\n\n\n\n<p>1\ufe0f\u20e3 <strong>Client makes an RPC request<\/strong> (calls a function remotely).<br>2\ufe0f\u20e3 <strong>RPC framework serializes the request<\/strong> (converts data into a transportable format).<br>3\ufe0f\u20e3 <strong>Server receives and processes the request<\/strong>.<br>4\ufe0f\u20e3 <strong>RPC framework deserializes the response<\/strong> and returns it to the client.<\/p>\n\n\n\n<p>\ud83d\udccc <strong>Example of an RPC Call Flow:<\/strong><\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">Client  \u2500\u2500&gt; RPC Framework \u2500\u2500&gt; Network \u2500\u2500&gt; Server  \nClient  &lt;\u2500\u2500 RPC Framework &lt;\u2500\u2500 Network &lt;\u2500\u2500 Server Response\n<\/code><\/span><\/pre>\n\n\n<p>\ud83d\udca1 <strong>Think of it like calling a function, but it runs on another server!<\/strong> \ud83d\ude80<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\ud83d\udd39 Popular RPC Frameworks<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><strong>RPC Framework<\/strong><\/th><th><strong>Used For<\/strong><\/th><th><strong>Protocol<\/strong><\/th><th><strong>Serialization Format<\/strong><\/th><\/tr><\/thead><tbody><tr><td><strong>gRPC<\/strong><\/td><td>Microservices, Cloud APIs<\/td><td>HTTP\/2<\/td><td>Protocol Buffers (ProtoBuf)<\/td><\/tr><tr><td><strong>Apache Thrift<\/strong><\/td><td>Cross-language RPC<\/td><td>TCP, HTTP<\/td><td>Compact Binary Format<\/td><\/tr><tr><td><strong>JSON-RPC<\/strong><\/td><td>Web APIs, JavaScript-based Apps<\/td><td>HTTP, WebSockets<\/td><td>JSON<\/td><\/tr><tr><td><strong>XML-RPC<\/strong><\/td><td>Legacy Systems<\/td><td>HTTP<\/td><td>XML<\/td><\/tr><tr><td><strong>ZeroMQ (\u00d8MQ)<\/strong><\/td><td>High-performance messaging<\/td><td>Custom (No built-in protocol)<\/td><td>Custom<\/td><\/tr><tr><td><strong>Dapr<\/strong><\/td><td>Cloud-Native Applications<\/td><td>HTTP\/gRPC<\/td><td>JSON\/ProtoBuf<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\ud83d\udd39 Why Use an RPC Framework?<\/strong><\/h2>\n\n\n\n<p>\u2705 <strong>Simplicity<\/strong> \u2192 Developers call remote functions like local functions.<br>\u2705 <strong>High Performance<\/strong> \u2192 Many frameworks (like gRPC) use <strong>binary serialization<\/strong> for fast data transmission.<br>\u2705 <strong>Cross-Language Support<\/strong> \u2192 Works across different programming languages (e.g., Python client calling a Go server).<br>\u2705 <strong>Streaming Support<\/strong> \u2192 Some frameworks (e.g., gRPC) support <strong>bidirectional streaming<\/strong>.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\ud83d\udd39 gRPC Example (Python)<\/strong><\/h2>\n\n\n\n<p><strong>Define an RPC Service (<code>hello.proto<\/code>):<\/strong><\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">syntax = <span class=\"hljs-string\">\"proto3\"<\/span>;\n\nservice Greeter {\n  rpc SayHello (HelloRequest) returns (HelloReply);\n}\n\nmessage HelloRequest {\n  string name = <span class=\"hljs-number\">1<\/span>;\n}\n\nmessage HelloReply {\n  string message = <span class=\"hljs-number\">1<\/span>;\n}\n<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>\u2705 The <strong>RPC framework<\/strong> handles serialization, networking, and responses automatically!<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\ud83c\udfaf Final Thoughts<\/strong><\/h2>\n\n\n\n<p>\ud83d\udd25 <strong>An RPC framework helps build high-performance distributed systems efficiently!<\/strong> \ud83d\udd25<br>\u2705 <strong>Best for:<\/strong> Microservices, Cloud APIs, and High-Speed Communication.<br>\u2705 <strong>Best choice:<\/strong> <strong>gRPC for modern systems, Thrift for cross-language, and JSON-RPC for web apps.<\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Difference Between RPC and RPC Framework<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><strong>Aspect<\/strong><\/th><th><strong>RPC (Remote Procedure Call)<\/strong><\/th><th><strong>RPC Framework<\/strong><\/th><\/tr><\/thead><tbody><tr><td><strong>Definition<\/strong><\/td><td>A <strong>concept<\/strong> that allows calling functions on a remote server as if they were local.<\/td><td>A <strong>set of tools, libraries, and protocols<\/strong> that implement RPC functionality.<\/td><\/tr><tr><td><strong>Functionality<\/strong><\/td><td>Enables communication between client and server in distributed systems.<\/td><td>Provides <strong>ready-to-use implementations<\/strong> for handling RPC calls, serialization, security, and networking.<\/td><\/tr><tr><td><strong>Example Concept<\/strong><\/td><td>A client requests a function (<code>getUserDetails()<\/code>) on a remote server.<\/td><td>A framework like <strong>gRPC, Apache Thrift, or JSON-RPC<\/strong> handles the networking, serialization, and execution of <code>getUserDetails()<\/code>.<\/td><\/tr><tr><td><strong>Transport Mechanism<\/strong><\/td><td>Can work over <strong>HTTP, TCP, UDP, WebSockets, etc.<\/strong><\/td><td>Uses specific transport mechanisms like <strong>HTTP\/2 (gRPC)<\/strong>, <strong>TCP (Thrift)<\/strong>, or <strong>HTTP (JSON-RPC)<\/strong>.<\/td><\/tr><tr><td><strong>Serialization<\/strong><\/td><td>Requires a way to encode and decode data (e.g., JSON, XML, Binary).<\/td><td>Built-in <strong>serialization formats<\/strong> like <strong>ProtoBuf (gRPC)<\/strong>, <strong>JSON (JSON-RPC)<\/strong>, or <strong>Binary (Thrift)<\/strong>.<\/td><\/tr><tr><td><strong>Security<\/strong><\/td><td>Must be implemented separately (e.g., authentication, encryption).<\/td><td>Many frameworks provide built-in <strong>TLS encryption, authentication, and access control<\/strong>.<\/td><\/tr><tr><td><strong>Cross-Language Support<\/strong><\/td><td>Requires manual implementation for different languages.<\/td><td>Provides <strong>auto-generated client and server code<\/strong> for multiple languages (e.g., Python, Java, Go, C++).<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">How RPC Works (Conceptually)?<\/h2>\n\n\n\n<p>1\ufe0f\u20e3 <strong>Client Calls a Function<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A client program calls a function (<code>getUserDetails()<\/code>) that is actually located on a remote server.<\/li>\n<\/ul>\n\n\n\n<p>2\ufe0f\u20e3 <strong>Request Serialization<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The function call&#8217;s parameters (data) are <strong>converted into a format<\/strong> that can be transmitted over a network (e.g., JSON, Protocol Buffers, XML, Binary).<\/li>\n<\/ul>\n\n\n\n<p>3\ufe0f\u20e3 <strong>Network Transmission<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The serialized data is <strong>sent over a network<\/strong> (via HTTP, TCP, UDP, WebSockets, etc.).<\/li>\n<\/ul>\n\n\n\n<p>4\ufe0f\u20e3 <strong>Server Receives the Request<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The <strong>server&#8217;s RPC system<\/strong> <strong>deserializes<\/strong> the request and calls the <strong>actual function<\/strong> on the server.<\/li>\n<\/ul>\n\n\n\n<p>5\ufe0f\u20e3 <strong>Function Execution &amp; Response<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The <strong>server executes the function<\/strong> (<code>getUserDetails()<\/code>) and sends the <strong>response back<\/strong> to the client.<\/li>\n<\/ul>\n\n\n\n<p>6\ufe0f\u20e3 <strong>Client Receives the Response<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The client <strong>deserializes<\/strong> the response and continues execution as if the function ran locally.<\/li>\n<\/ul>\n\n\n\n<p>\ud83d\udccc <strong>RPC Conceptual Flow:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">pgsqlCopyEdit<code>Client \u2500\u2500\u2500&gt; (Serialize Data) \u2500\u2500\u2500&gt; Network \u2500\u2500\u2500&gt; Server  \nServer \u2500\u2500\u2500&gt; (Execute Function) \u2500\u2500\u2500&gt; Return Response \u2500\u2500\u2500&gt; Client  \n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\ud83d\udd39 RPC vs. Normal Function Calls<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Feature<\/th><th>Local Function Call<\/th><th>Remote Procedure Call (RPC)<\/th><\/tr><\/thead><tbody><tr><td><strong>Execution Location<\/strong><\/td><td>Runs on the <strong>same machine<\/strong><\/td><td>Runs on a <strong>remote server<\/strong><\/td><\/tr><tr><td><strong>Data Passing<\/strong><\/td><td>Direct memory access<\/td><td>Data is <strong>serialized and sent over the network<\/strong><\/td><\/tr><tr><td><strong>Performance<\/strong><\/td><td>Fast (no network delay)<\/td><td>Slower (network latency)<\/td><\/tr><tr><td><strong>Complexity<\/strong><\/td><td>Simple<\/td><td>Requires handling <strong>network failures, serialization, security<\/strong><\/td><\/tr><tr><td><strong>Use Case<\/strong><\/td><td>Local programs<\/td><td><strong>Microservices, Cloud APIs, Distributed Systems<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\ud83d\udd39 Real-World Use Cases of RPC<\/strong><\/h2>\n\n\n\n<p>\u2705 <strong>Microservices Communication<\/strong> \u2192 Services talk to each other in cloud-native applications.<br>\u2705 <strong>Database Requests<\/strong> \u2192 Clients call database functions remotely.<br>\u2705 <strong>Remote System Administration<\/strong> \u2192 Commands are executed on remote servers.<br>\u2705 <strong>Game Servers &amp; Multiplayer Apps<\/strong> \u2192 Actions from one player affect other players over a network.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\ud83d\udd39 List of All Popular RPC Frameworks<\/strong><\/h2>\n\n\n\n<p>RPC frameworks <strong>simplify remote function execution<\/strong> by handling networking, serialization, and security. Below is a list of widely used <strong>RPC frameworks<\/strong> categorized based on their use cases.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>1\ufe0f\u20e3 Modern High-Performance RPC Frameworks<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><strong>Framework<\/strong><\/th><th><strong>Description<\/strong><\/th><th><strong>Protocol<\/strong><\/th><th><strong>Serialization Format<\/strong><\/th><th><strong>Best For<\/strong><\/th><\/tr><\/thead><tbody><tr><td><strong>gRPC<\/strong><\/td><td>Google\u2019s high-performance RPC framework<\/td><td><strong>HTTP\/2<\/strong><\/td><td><strong>Protocol Buffers (ProtoBuf)<\/strong><\/td><td>Microservices, Cloud APIs<\/td><\/tr><tr><td><strong>Apache Thrift<\/strong><\/td><td>Cross-language RPC system<\/td><td><strong>TCP, HTTP<\/strong><\/td><td><strong>Compact Binary, JSON, Simple JSON<\/strong><\/td><td>Large-scale distributed systems<\/td><\/tr><tr><td><strong>Cap\u2019n Proto<\/strong><\/td><td>High-speed serialization and RPC<\/td><td><strong>Custom (No extra encoding needed)<\/strong><\/td><td><strong>Cap\u2019n Proto (Zero Parsing Overhead)<\/strong><\/td><td>Low-latency systems<\/td><\/tr><tr><td><strong>Dapr<\/strong><\/td><td>Cloud-native distributed application runtime<\/td><td><strong>HTTP, gRPC<\/strong><\/td><td><strong>JSON, ProtoBuf<\/strong><\/td><td>Microservices &amp; Kubernetes<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>2\ufe0f\u20e3 Web-Based RPC Frameworks<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><strong>Framework<\/strong><\/th><th><strong>Description<\/strong><\/th><th><strong>Protocol<\/strong><\/th><th><strong>Serialization Format<\/strong><\/th><th><strong>Best For<\/strong><\/th><\/tr><\/thead><tbody><tr><td><strong>JSON-RPC<\/strong><\/td><td>Lightweight RPC using JSON over HTTP\/WebSockets<\/td><td><strong>HTTP, WebSockets<\/strong><\/td><td><strong>JSON<\/strong><\/td><td>Web applications, JavaScript-based systems<\/td><\/tr><tr><td><strong>XML-RPC<\/strong><\/td><td>Simple RPC protocol using XML over HTTP<\/td><td><strong>HTTP<\/strong><\/td><td><strong>XML<\/strong><\/td><td>Legacy systems<\/td><\/tr><tr><td><strong>WAMP (Web Application Messaging Protocol)<\/strong><\/td><td>Web-based RPC with real-time pub\/sub<\/td><td><strong>WebSockets, TCP<\/strong><\/td><td><strong>JSON, MsgPack, CBOR<\/strong><\/td><td>WebSockets-based APIs<\/td><\/tr><tr><td><strong>Falcor<\/strong><\/td><td>Netflix\u2019s RPC for efficient data fetching<\/td><td><strong>HTTP<\/strong><\/td><td><strong>JSON<\/strong><\/td><td>Web applications<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>3\ufe0f\u20e3 Messaging-Based RPC Frameworks<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><strong>Framework<\/strong><\/th><th><strong>Description<\/strong><\/th><th><strong>Protocol<\/strong><\/th><th><strong>Serialization Format<\/strong><\/th><th><strong>Best For<\/strong><\/th><\/tr><\/thead><tbody><tr><td><strong>ZeroMQ (\u00d8MQ)<\/strong><\/td><td>High-performance messaging library<\/td><td><strong>TCP, IPC, Multicast<\/strong><\/td><td><strong>Custom<\/strong><\/td><td>Low-latency, real-time systems<\/td><\/tr><tr><td><strong>Apache Avro<\/strong><\/td><td>Schema-based RPC with a focus on Big Data<\/td><td><strong>TCP, HTTP<\/strong><\/td><td><strong>Avro Binary, JSON<\/strong><\/td><td>Big Data, Streaming (Kafka, Hadoop)<\/td><\/tr><tr><td><strong>MessagePack-RPC<\/strong><\/td><td>Lightweight binary-based RPC<\/td><td><strong>TCP, UDP<\/strong><\/td><td><strong>MessagePack<\/strong><\/td><td>IoT &amp; high-performance applications<\/td><\/tr><tr><td><strong>Nanomsg<\/strong><\/td><td>Simplified version of ZeroMQ<\/td><td><strong>TCP, IPC<\/strong><\/td><td><strong>Custom<\/strong><\/td><td>High-speed messaging<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>4\ufe0f\u20e3 Enterprise &amp; Legacy RPC Frameworks<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><strong>Framework<\/strong><\/th><th><strong>Description<\/strong><\/th><th><strong>Protocol<\/strong><\/th><th><strong>Serialization Format<\/strong><\/th><th><strong>Best For<\/strong><\/th><\/tr><\/thead><tbody><tr><td><strong>CORBA (Common Object Request Broker Architecture)<\/strong><\/td><td>Classic RPC framework for enterprise systems<\/td><td><strong>IIOP (TCP-based)<\/strong><\/td><td><strong>Binary (IDL-based)<\/strong><\/td><td>Legacy enterprise applications<\/td><\/tr><tr><td><strong>RMI (Remote Method Invocation)<\/strong><\/td><td>Java\u2019s built-in RPC mechanism<\/td><td><strong>JRMP (Java Remote Method Protocol)<\/strong><\/td><td><strong>Java Serialization<\/strong><\/td><td>Java-based distributed applications<\/td><\/tr><tr><td><strong>Hessian<\/strong><\/td><td>Lightweight binary-based RPC<\/td><td><strong>HTTP<\/strong><\/td><td><strong>Hessian Binary Format<\/strong><\/td><td>Java &amp; cross-platform systems<\/td><\/tr><tr><td><strong>TARS<\/strong><\/td><td>Tencent\u2019s distributed RPC framework<\/td><td><strong>TCP, HTTP<\/strong><\/td><td><strong>TARS, ProtoBuf, JSON<\/strong><\/td><td>Large-scale microservices<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>5\ufe0f\u20e3 Blockchain &amp; Decentralized RPC Frameworks<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><strong>Framework<\/strong><\/th><th><strong>Description<\/strong><\/th><th><strong>Protocol<\/strong><\/th><th><strong>Serialization Format<\/strong><\/th><th><strong>Best For<\/strong><\/th><\/tr><\/thead><tbody><tr><td><strong>Ethereum JSON-RPC<\/strong><\/td><td>RPC API for Ethereum blockchain<\/td><td><strong>HTTP, WebSockets<\/strong><\/td><td><strong>JSON<\/strong><\/td><td>Blockchain applications<\/td><\/tr><tr><td><strong>Bitcoin RPC<\/strong><\/td><td>RPC interface for Bitcoin nodes<\/td><td><strong>HTTP<\/strong><\/td><td><strong>JSON<\/strong><\/td><td>Cryptocurrency development<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\ud83d\udd39 Choosing the Right RPC Framework<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><strong>Use Case<\/strong><\/th><th><strong>Recommended Framework<\/strong><\/th><\/tr><\/thead><tbody><tr><td><strong>Microservices &amp; Cloud<\/strong><\/td><td>gRPC, Thrift, Dapr<\/td><\/tr><tr><td><strong>Web-Based RPC<\/strong><\/td><td>JSON-RPC, WAMP, Falcor<\/td><\/tr><tr><td><strong>Big Data &amp; Streaming<\/strong><\/td><td>Apache Avro, MessagePack-RPC<\/td><\/tr><tr><td><strong>Low-Latency &amp; High-Performance<\/strong><\/td><td>ZeroMQ, Cap\u2019n Proto<\/td><\/tr><tr><td><strong>Enterprise &amp; Legacy Apps<\/strong><\/td><td>CORBA, RMI, Hessian<\/td><\/tr><tr><td><strong>Blockchain Apps<\/strong><\/td><td>Ethereum JSON-RPC, Bitcoin RPC<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\ud83c\udfaf Final Thoughts<\/strong><\/h2>\n\n\n\n<p>\u2705 <strong>If you need a high-performance modern RPC framework<\/strong>, use <strong>gRPC or Apache Thrift<\/strong>.<br>\u2705 <strong>For web-based applications<\/strong>, <strong>JSON-RPC<\/strong> is a lightweight option.<br>\u2705 <strong>For low-latency, high-speed messaging<\/strong>, <strong>ZeroMQ<\/strong> or <strong>Cap\u2019n Proto<\/strong> are great choices.<br>\u2705 <strong>For distributed systems and big data<\/strong>, <strong>Apache Avro<\/strong> is recommended.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>\ud83d\udd39 Default RPC Methods in Different Scenarios<\/strong><\/h2>\n\n\n\n<p>Below is a breakdown of <strong>what happens by default<\/strong> when you call a remote function in different environments.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><strong>Scenario<\/strong><\/th><th><strong>What Happens By Default?<\/strong><\/th><th><strong>Default RPC Framework<\/strong><\/th><\/tr><\/thead><tbody><tr><td><strong>PHP in XAMPP (Apache Server)<\/strong><\/td><td>No native RPC; you must use JSON-RPC, SOAP, or REST<\/td><td>\u274c None (you must specify)<\/td><\/tr><tr><td><strong>Java Calling Remote Functions<\/strong><\/td><td>Uses Java RMI (Remote Method Invocation)<\/td><td>\u2705 <strong>Java RMI<\/strong><\/td><\/tr><tr><td><strong>Python Calling a Remote Function<\/strong><\/td><td>Uses built-in <code>xmlrpc.client<\/code> for XML-RPC<\/td><td>\u2705 <strong>XML-RPC<\/strong><\/td><\/tr><tr><td><strong>Node.js Communicating with Remote Services<\/strong><\/td><td>Typically uses HTTP API calls (REST)<\/td><td>\u2705 <strong>HTTP (REST)<\/strong><\/td><\/tr><tr><td><strong>.NET \/ C# Calling Remote Services<\/strong><\/td><td>Uses WCF (Windows Communication Foundation)<\/td><td>\u2705 <strong>WCF (SOAP\/XML-RPC)<\/strong><\/td><\/tr><tr><td><strong>C++ Distributed Systems<\/strong><\/td><td>Uses CORBA (Common Object Request Broker Architecture)<\/td><td>\u2705 <strong>CORBA<\/strong><\/td><\/tr><tr><td><strong>Web Browsers Calling Remote Functions<\/strong><\/td><td>Uses AJAX (JavaScript HTTP Requests)<\/td><td>\u2705 <strong>REST over HTTP (AJAX, Fetch API)<\/strong><\/td><\/tr><tr><td><strong>Linux System Calls<\/strong><\/td><td>Uses <code>gRPC<\/code> or <code>DBus<\/code> for inter-process communication<\/td><td>\u2705 <strong>gRPC, DBus<\/strong><\/td><\/tr><tr><td><strong>Blockchain Smart Contracts (Ethereum, Bitcoin, etc.)<\/strong><\/td><td>Uses JSON-RPC to communicate with nodes<\/td><td>\u2705 <strong>JSON-RPC<\/strong><\/td><\/tr><\/tbody><\/table><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>What is RPC (Remote Procedure Call)? \ud83d\udd39 What is RPC (Remote Procedure Call)? Remote Procedure Call (RPC) is a protocol that allows a computer program to execute a function or&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[2],"tags":[],"class_list":["post-48535","post","type-post","status-publish","format-standard","hentry","category-uncategorised"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/48535","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=48535"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/48535\/revisions"}],"predecessor-version":[{"id":48536,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/48535\/revisions\/48536"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=48535"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=48535"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=48535"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}