liveBook · Manning

Remote procedure call

As explained in Elixir in Action, Third Edition

A remote procedure call, or remote function call, is an invocation of an operation on another process or machine presented as though it were a local function call.

Remote procedure calls invoke functions on other nodes while returning a result to the caller. They help distribute load and preserve service when nodes fail. section 12.0 section 12.1.5

Use RPC when a fire-and-forget process operation is not sufficient:

  • Call :rpc.call/4 with a target node and MFA to execute a function remotely and obtain its result. section 12.1.5
  • Invoke functions across multiple nodes and collect their results when coordinating cluster-wide work such as replication. section 12.1.5
  • Treat message passing, copied message contents, delivery uncertainty, and response protocols as part of the communication design. section 12.0

The :rpc service builds on transparent message passing: it sends an MFA to each node’s registered :rex process, applies the function, and returns the response. section 12.1.5

iex(node1@localhost)1> :rpc.call(:node2@localhost, Kernel, :abs, [-1])
1

A minimal IEx call invokes Kernel.abs(-1) on node2 and returns 1 to node1. section 12.1.5

How Elixir in Action, Third Edition covers it

How deep it goes
Explains invocation, returned results, message costs, and the :rex implementation, while deferring broader distributed-system challenges.
Examples
Demonstrates Kernel.abs(-1) executed on node2 through an IEx :rpc.call/4 expression.
What it assumes
Assumes familiarity with Elixir functions, nodes, processes, messages, and MFA identifiers.
What you can do after
Apply it via :rpc.call/4 to execute functions remotely and retrieve results from one or multiple nodes.
How it connects
Connects remote procedure calls with message passing, Erlang processes, distributed systems, synchronous calls, and replication.

Also explained in

Compare how 5 books explain remote procedure call →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Elixir in Action, Third Edition. The section links point to the parts of the book it draws on.