Notesencoding🌱 seedling
RPC
Also: Remote Procedure Call · Location Transparency · Remote Call
RPC makes a call to another process look like a local function call. The illusion is leaky: remote calls have unpredictable latency, no shared memory and partial failure, where a timeout leaves the outcome unknown.
Why it exists
Calling a function is the most natural programming model, and generated stubs spare you from writing encoding and transport code by hand.
How it works
- An interface definition generates client stubs and server skeletons; arguments and results are serialized for the wire.
- Older systems (CORBA, Java RMI, DCOM, SOAP) aimed at full location transparency, and mostly suffered for it.
- Remote calls differ in four ways: latency, no shared memory (arguments are copied), concurrency, and Partial Failure.
- A timeout has three possible causes: request lost, reply lost after the work was done, or server still working. So retries need Idempotency.
- Modern frameworks make the network explicit: deadlines, status codes, async and streaming calls.
Trade-offs
| Gains | Costs |
|---|---|
| typed, generated clients; compact binary encoding | tighter coupling between client and server than messages |
| streaming and deadlines in frameworks like gRPC | needs HTTP/2 or custom tooling; less debuggable than JSON |
| feels like local code | the feeling hides latency and failure |
In practice
- gRPC (Google, 2015, the successor to Stubby) is the dominant RPC framework between services.
- Compatibility direction: servers upgrade first, so requests need backward and responses forward compatibility.
Pitfalls
- Chatty interfaces designed as if calls were free.
- Treating a timeout as "it failed" and retrying a non-idempotent call.
Connections
- Part of
- Encoding
- Learn first
- Serialization
- Contrasts with
- Message BrokerMessage PassingREST
- In real systems
- gRPC
Recall
These cards are also in your review deck, scheduled with spaced repetition.