References
What is gRPC?
gRPC is a modern open-source high-performance Remote Procedure Call (RPC) framework developed by Google. It can efficiently connect services in and across data centers with pluggable support for load balancing, tracing, health checking and authentication.
Why gRPC over REST?
Protobuf instead of JSON/XML
REST uses JSON for sending and receiving messages. JSON is flexible, text-based and human-readable but it is not fast enough or light-weight enough for transmitting data between systems. gRPC uses Protobuf(protocol buffers) messaging format which is faster and more efficient for data transmission
First-class support for code generation
REST needs third-party tools to generate the code for API calls. gRPC comes with an in-built protoc compiler which provides the code generation features by default.
Built on HTTP 2
REST is built on HTTP 1.1 which uses a request-response model of communication. gRPC uses HTTP2 so that it supports client-response communication and bidirectional streaming.
Works across languages and platforms
Since the code can be generated for any language, it is easy to create micro-services in any language to interact with each other
4 Types of API in gRPC
- Unary
- Server Streaming
- Client Streaming
- Bidirectional
Following is an example of the four types of APIs. You can understand it further when we are implementing the sample.
|
|