RPC (Remote Procedure Call) is a communication protocol that allows a program to execute a function or procedure on a remote machine as if it were a local call. It abstracts the complexity of network communication, enabling distributed systems to work together seamlessly.
RPC lets a client program call a function that runs on a different process or server without writing explicit networking code. From the developer's perspective, the call looks and feels like a regular local function call. Under the hood, the framework handles serializing arguments, sending them over the network, executing the function remotely, and returning the result.
When a client makes an RPC call, a local stub (or proxy) intercepts it and serializes the arguments into a wire format — a process called marshalling. The serialized data is sent over a transport layer (commonly TCP or HTTP) to the remote server. The server deserializes the arguments, executes the actual function, then marshals the return value and sends it back to the client, which unmarshals and returns the result as if the function ran locally.
Popular modern RPC frameworks include gRPC (by Google, using Protocol Buffers and HTTP/2), Apache Thrift, and JSON-RPC. gRPC is widely used in microservices for its strong typing, code generation, and efficiency. Older systems may use XML-RPC or CORBA, while REST APIs share some conceptual overlap but are not strictly RPC.
REST treats network resources as addressable URLs using HTTP verbs, making it stateless and cache-friendly, while RPC focuses on invoking specific actions or functions by name. RPC typically has tighter coupling between client and server because both must agree on the exact function signatures and serialization format. REST is more widely understood for public APIs, while RPC shines in internal, high-performance, or low-latency service-to-service communication.
The biggest pitfall of RPC is forgetting that the network is unreliable — remote calls can fail, time out, or be duplicated in ways local calls never are. Developers must handle partial failures, implement retries with idempotency, and set appropriate timeouts. Ignoring network latency and treating RPC calls as synchronous free operations can quickly become a performance bottleneck in high-load systems.
© RM Full Stack & AI Engineer · All guides · Roadmaps · Open the app