What is gRPC?
Table of contents
What is gRPC?
- gRPC is a high-performance Remote Procedure Call (RPC) framework.
- gRPC enables efficient and simple communication.
- Microservices are built using different languages, and a lot of information is exchanged between them. So gRPC is used to communicate between these microservices.
- gRPC is language agnostic.
By default, gRPC uses Protocol Buffers (although it can be used with other data formats such as JSON).
Protocol Buffers
- Protocol buffers provide a language-neutral, extensible mechanism for serializing structured data. Itโs like JSON, except it's smaller and faster, and it generates native language bindings.
- Protocol buffers are a combination of the definition language (created in .proto files), the code that the proto compiler generates to interface with data, language-specific runtime libraries, and the serialization format for data that is written to a file (or sent across a network connection).
- Some of the advantages of using protocol buffers include:
- Compact data storage
- Fast parsing
- Availability in many programming languages
How gRPC works?
- It works just calling a normal function.
- Client/service has a generated stub that has the same methods as the gRPC server.
- These stubs call the gRPC under the hood to exchange information so that we can focus on the core logic.
- gRPC uses HTTP/2 as communication transfer protocol:
- Faster
- Lighter to transport
- Robust and performant
- Multiplexing multiple requests and responses over a single TCP connection.
- Server push (single request from a client, multiple responses from server)
The End!
ย