A topic in the Open Knowledge Graph — a free, open map of 15,495 topics and the order to learn them in.

Remote Procedure Calls (RPC)

Graduate Depth 103 in the knowledge graph ☐ I know this ☆ Set as goal
3topics build on this
549prerequisites beneath it
See this on the map →
Defining and Calling FunctionsSocket Programming and Network APIs+1 more→→At-Least-Once Delivery SemanticsIdempotent Operations in Distributed Systems
RPC stubs marshalling IDL gRPC middleware failure-semantics

Core Idea

A remote procedure call lets a program call a function that runs on another machine using syntax that looks like an ordinary local call. Generated code called stubs does the hidden work: the client stub marshals (serializes) the arguments into a network message, and the server stub unmarshals them, calls the real function, and sends the result back. The classic design was described by Andrew Birrell and Bruce Nelson in 1984, and modern frameworks such as gRPC follow the same pattern. The local-call appearance is only partial, because remote calls add network delay, can fail partway, and cannot share memory.

How It's Best Learned

Write an interface definition, for example a small Protocol Buffers service with one method, generate the stubs, and call the method from a client. Then make the server slow, kill it mid-call, and drop replies, and ask students what the client can conclude in each case. Use these experiments to introduce at-most-once and at-least-once semantics and the value of idempotent operations.

Common Misconceptions

Explainer

Writing networked programs with raw sockets means building byte messages by hand, sending them, waiting and parsing replies. It is tedious and easy to get wrong. A remote procedure call hides that work behind a familiar abstraction: a function call. The client writes `balance = bank.get_balance(account_id)`, and the system arranges for `get_balance` to run on a server and return its answer.

The machinery has a standard shape, described by Andrew Birrell and Bruce Nelson of Xerox PARC in 1984. The programmer first writes the remote interface in an interface definition language (IDL). In gRPC that language is Protocol Buffers. A tool generates two pieces of code. The client stub has the same signature as the real function. When called, it marshals the arguments into a byte format, sends a request message and waits. The server stub receives the message, unmarshals the arguments, calls the real implementation and marshals the return value into a reply. Marshalling also settles representation differences between machines, such as byte order.

The local-call disguise is useful but imperfect. Three differences matter. First, latency: a local call takes nanoseconds, while a remote call takes at least a network round trip, often a millisecond or more. Second, no shared memory: arguments are copied, so passing a pointer or a large shared object does not work as it would locally. Third, and most important, partial failure. A local call either returns or the whole program fails. A remote call can fail in pieces. The request can be lost, the server can crash before or after doing the work, or the reply can be lost.

When a reply does not arrive, the client cannot tell which of these happened. Systems respond with defined call semantics. With at-least-once semantics, the client keeps retrying until it gets a reply, so the procedure may run more than once. That is safe only for idempotent operations, which have the same effect when repeated. With at-most-once semantics, the client gives each request a unique ID and the server discards duplicates, so the procedure never runs twice, though it may not run at all. True exactly-once execution needs extra machinery, such as durable logging of request IDs and results.

RPC frameworks such as gRPC and Apache Thrift remain central to building services. Good designs treat every remote call as something that can be slow or fail, and they set timeouts, retries and idempotence on purpose.

Practice Questions 4 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Combining Small Groups Within 5 → Number Bonds Within 5 → Number Bonds to 10 → Tens and Ones Place Value → Reading and Writing Three-Digit Numbers → Comparing Three-Digit Numbers → Comparing and Ordering Three-Digit Quantities → Comparing and Ordering Whole Numbers → Comparing Numbers 1 to 20 → Ordering Numbers to 20 → Number Line 0 to 20 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Opposites and Additive Inverses → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Boolean Algebra → Boolean Type and Truth Values → Comparison Operators and Boolean Tests → Logical Operators and Boolean Algebra → Boolean Algebra and Fundamental Laws → Logic Gates Fundamentals → Implementing Boolean Functions with Gates → Karnaugh Map Simplification → Combinational Circuit Design → Flip-Flops and Latches → Finite State Machines (FSMs) → Deterministic Finite Automata (DFA) → Nondeterministic Finite Automata (NFA) → Regular Language Recognition Algorithms → DFA Properties and Minimization Algorithms → Regular Languages: Definition and Characterization → Context-Free Grammars (CFGs) → Context-Free Grammar Properties and Ambiguity → Parse Trees, Derivations, and Ambiguity in CFGs → Context-Free Grammars in Compiler Design → Abstract Syntax Trees (ASTs) → Symbol Tables and Scope Resolution → Semantic Analysis Phase → Scope and Binding Resolution → Scope, Shadowing, and Variable Lifetime → Parameter Passing: Value vs. Reference → Remote Procedure Calls (RPC)

Longest path: 104 steps · 549 total prerequisite topics

Prerequisites (3)

Leads To (2)