gRPC, explained
gRPC was released by Google in 2015 and is a Cloud Native Computing Foundation project. Services and messages are defined in .proto files, and code generators produce client stubs and server interfaces for languages such as Go, Java, Python, C# and TypeScript.
service Invoices {
rpc GetInvoice (GetInvoiceRequest) returns (Invoice);
}
message Invoice {
string id = 1;
int64 amount_cents = 2;
}Running over HTTP/2 gives gRPC multiplexed connections and four call types: unary, server streaming, client streaming and bidirectional streaming. The binary Protocol Buffers encoding is compact and fast, which makes gRPC popular for internal service-to-service traffic. Browsers cannot speak native gRPC directly, so public web APIs usually use REST or GraphQL, or gRPC-Web through a proxy.
Protobuf compatibility depends on field numbers, not names. Reusing or renumbering a field, changing its type or removing it without reserving the number can silently corrupt data for older clients, a classic breaking change.
Related terms
- GraphQL: GraphQL is a query language and runtime for APIs where clients request exactly the fields they need from a typed schema, usually through a single endpoint.
- REST API: A REST API is an HTTP API organised around resources identified by URLs and manipulated with standard methods such as GET, POST, PUT, PATCH and DELETE.
- Backward compatibility: An API change is backward compatible when every client built against the previous version keeps working, with the same behavior, after the change ships.