How it works
You describe services and messages in a .proto file, and gRPC's tools generate client and server code in many languages (Go, Java, Kotlin, Python, C#, Node.js and more). Calls travel over HTTP/2 as Protocol Buffers, a binary format that is smaller and quicker to parse than JSON. Besides simple request and response, it supports streaming in either direction or both at once.
Google created it from its internal RPC system and open-sourced it in 2015; it is now a Cloud Native Computing Foundation project. It is common between microservices and in some mobile and device clients. Browsers cannot speak it directly, so web apps need gRPC-Web or the Connect protocol through a proxy, and binary traffic is harder to inspect than JSON.
gRPC pros and cons
Pros
- Compact binary messages and HTTP/2 make calls efficient
- Strict contracts in .proto files, with generated code in many languages
- Built-in streaming in both directions
Cons
- Browsers need gRPC-Web or Connect and a proxy
- Binary payloads are harder to read and debug by hand
- More setup than a JSON API for small projects
When to use gRPC
Pick it when
- Internal traffic between microservices written in different languages
- High-volume or streaming connections where efficiency matters
Skip it when
- A public API called straight from browsers or by third parties
gRPC pricing
gRPC vs the alternatives
Related terms
More in Backend and APIs
API styles