Software-Engineering

gRPC (gRPC Remote Procedure Call)

What is gRPC?

gRPC is a high-performance, open-source universal RPC framework developed by Google. It allows a client application to directly call a method on a server application on a different machine as if it were a local object. It is based on the HTTP/2 protocol and uses Protocol Buffers (Protobuf) as its interface description language and data serialization format.

How it Works

gRPC follows the RPC (Remote Procedure Call) model.

  1. Protocol Buffers (Protobuf): You define the service and the structure of the payload in a .proto file. This is a language-neutral way to serialize structured data.
  2. Code Generation: Using the protoc compiler, you generate client and server code in your preferred languages (Go, Java, Python, etc.) from the .proto definition.
  3. HTTP/2 Transport: gRPC uses HTTP/2 under the hood, which supports:
    • Multiplexing: Multiple requests over a single TCP connection.
    • Binary Framing: Data is sent in binary, not text (like JSON), making it much smaller and faster to parse.
    • Streaming: Supports bi-directional streaming (client-side, server-side, or both).

Why We Need It & When to Use

gRPC is designed for low latency and high throughput communication, primarily between microservices.

Use gRPC when:

Other Options

Pros and Cons

Pros

Cons