Skip to main content

RPC

Remote Procedure Call

Updated 3 min read

Share this page

Send the link, quote the definition with a link back, or show it as a card on your own site.

https://softwaredictionary.org/terms/rpc

In short

RPC is a communication style in which a program calls a function that runs on another machine as if it were a local function, hiding the network in between.

What is RPC?

A remote procedure call lets code on one computer run a function on another computer through what looks like an ordinary function call, such as getUser(42). Behind the scenes, the arguments are serialized, sent over the network, and executed on the server, and the result is sent back and returned to the caller. The idea dates back to the late 1970s and early 1980s and still underpins much of how distributed systems and microservices talk to each other.

An RPC system usually starts from an interface definition that lists the available procedures with their parameters and return types. From it, tools generate client stubs, local functions that handle serialization and networking, and server code that receives calls and invokes the real implementation. Popular implementations include gRPC, which uses Protocol Buffers over HTTP/2, JSON-RPC, a lightweight protocol that sends JSON messages, and Apache Thrift. JSON-RPC 2.0, for example, is the message format behind the Language Server Protocol used by code editors and the Model Context Protocol used by AI tools.

RPC is like phoning a colleague and asking them to calculate the quarterly total: you ask for an action by name and wait for the answer, without caring how they do it. The catch is that the network is never truly invisible. A remote call can be slow, time out, or fail halfway through, so good RPC clients set timeouts, retry carefully with exponential backoff, and prefer idempotent operations.

RPC is most often compared with REST. RPC is organized around actions, like createInvoice or sendReminder, while REST is organized around resources, like /invoices/42, that are manipulated with standard HTTP methods. RPC tends to feel natural for internal service-to-service calls with a strict contract, and REST is more common for public web APIs. Note that gRPC is one specific RPC framework, not a synonym for RPC in general.

Key takeaways

  • RPC makes a call to code on another machine look like a local function call.
  • Client stubs serialize the arguments and send them; the server runs the function and returns the result.
  • gRPC, JSON-RPC, and Apache Thrift are common RPC implementations.
  • Remote calls can fail or time out, so they need timeouts and careful retries.
  • RPC is action-oriented, while REST is resource-oriented.

Example

A tiny JSON-RPC 2.0 clientjavascript
// A minimal client stub: remote calls look like local ones
async function call(method, params) {
  const res = await fetch("https://api.example.com/rpc", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ jsonrpc: "2.0", method, params, id: 1 }),
  });
  const reply = await res.json(); // {"jsonrpc":"2.0","result":{...},"id":1}
  if (reply.error) throw new Error(reply.error.message);
  return reply.result;
}

// The caller just names the procedure and passes arguments
const user = await call("getUser", { id: 42 });

Readers ask

What is the difference between RPC and REST?

RPC exposes actions you call by name, such as transferMoney, usually through a single endpoint or a generated client. REST exposes resources at URLs, such as /accounts/42, and uses standard HTTP methods and status codes to act on them.

Is gRPC the same as RPC?

No. RPC is the general idea of calling remote functions, and gRPC is one open-source framework that implements it, using Protocol Buffers for messages and HTTP/2 for transport.

Is RPC synchronous?

Conceptually, the caller waits for a result, like a normal function call. In practice, modern RPC libraries expose calls as asynchronous functions or promises so the caller isn't blocked, and some also support streaming and one-way notifications.

See also

Spotted a mistake or something missing on this page?Suggest an edit

Read a random page
Open today's review
Switch to the dark theme
Read this page in Türkçe

More

Settings