gRPC

gRPC is a high-performance RPC framework developed at Google, using HTTP/2 as the transport and Protocol Buffers (protobuf) as the schema and serialization format. It is the default choice for internal service-to-service communication at many companies running microservices in compiled languages.

How it works

Services are defined in .proto files specifying messages and RPC methods. A code generator produces strongly typed client and server stubs in target languages. Calls travel over HTTP/2 streams, allowing multiplexing and bidirectional streaming alongside the classic unary request-response.

Call patterns

  • Unary: single request, single response. The default.
  • Server streaming: single request, stream of responses.
  • Client streaming: stream of requests, single response.
  • Bidirectional streaming: both sides stream concurrently.

gRPC vs REST vs GraphQL

  • gRPC. Binary, schema-first, high performance, ideal for internal traffic. Browser support requires gRPC-Web.
  • REST. Text-based, browser-friendly, cache-friendly, looser typing.
  • GraphQL. Flexible field selection, single endpoint, strong typing, no streaming by default.
🔗

Subscribe to Sahil's Playbook

Clear thinking on product, engineering, and building at scale. No noise. One email when there's something worth sharing.
[email protected]
Subscribe
Mastodon