6 min read
0%

gRPC

Back to Blog
gRPC

gRPC

gRPC is a contract-first RPC system built around Protocol Buffers and HTTP/2. It is a strong fit for internal service-to-service traffic where you want strict schemas, generated clients, deadlines, and streaming. It is less about raw speed than about disciplined interfaces and predictable failure semantics across many teams.

Minimal Example

syntax = "proto3";

service InventoryService {
  rpc Reserve(ReserveRequest) returns (ReserveReply);
}

message ReserveRequest {
  string sku = 1;
  int32 quantity = 2;
}

message ReserveReply {
  bool accepted = 1;
  string reservation_id = 2;
}

What It Solves

  • Generates clients and servers from one schema so interface drift gets caught earlier.
  • Supports deadlines, metadata, and streaming as first-class transport concerns.
  • Works well for internal networks where both sides can adopt shared tooling.

Failure Modes

  1. Ignoring deadlines and letting slow downstream calls consume threads indefinitely.
  2. Breaking wire compatibility by renumbering or reusing protobuf field IDs.
  3. Choosing gRPC for internet-facing APIs where browsers and external consumers need simpler primitives.

Production Checklist

  • Set request deadlines explicitly and propagate cancellation across hops.
  • Treat protobuf field numbers as permanent and reserve removed fields.
  • Expose retry policy only for idempotent methods with clear status handling.

Closing

gRPC shines when teams want strong contracts and predictable runtime behavior. It is a poor fit when the ecosystem around the API is more important than transport discipline.


Canvas is not supported in your browser