Source
Remote procedure call
RPC definition and key properties.
RPC, REST and gRPC are different approaches to remote calling. They solve one problem: transmit a request over the network and receive a result, but they differ in interface style, level of formalization and typical application scenarios.
Source
REST
Architectural style, main limitations and properties.
Visualization of how the approaches work
Choose an approach and see how the request, response, and contract are formed between the parties.
How remote calls work
Choose an approach to see how request and response are formed
Request and response
Key properties
- Procedure call abstraction
- Focus on methods rather than resources
- Commonly uses binary serialization
What to keep in mind
Source
gRPC basics
Services, proto-contracts and types of RPC calls.
What do they have in common?
- They work on a client-server model and transmit requests over the network.
- They use data serialization and a contract between client and server.
- Require descriptions of errors, timeouts and retries.
How are they different?
RPC
- Focus on calling the method as a local function.
- Convenient for internal services and binary protocols.
- Client and server are often more strongly coupled.
REST
- Focus on resources and HTTP methods.
- Stateless and cached well.
- Better for public APIs and integrations.
gRPC
- The contract is described in .proto and generates code.
- Supports streaming calls.
- Well suited for microservices.
When to choose what
- RPC is convenient for internal services where speed and compact contracts are important.
- REST is suitable for public APIs and integrations where caching and interoperability are important.
- gRPC is good for microservices when a strict contract and streaming are needed.
