Table of Contents
gRPC is an open-source remote procedure call framework. It lets one program call a method implemented by another service. Teams typically define their services and message types in Protocol Buffers, generate client and server code, and exchange messages over HTTP/2.

How a gRPC call works
- Define the service in a
.protofile. For an inventory service,GetStockcould accept a product ID and return the quantity available. - Run the Protocol Buffers compiler and the gRPC plugin for your language. They generate message types and a client stub, plus server code you use to register your implementation.
- The client calls the stub with a request. The server runs the method and returns a response and a gRPC status. The same schema can serve a Go client and a Java server.
The stub makes a remote call look like a local method, but the call can still time out, fail to reach the server, or be canceled. HTTP/2 can carry multiple calls over one connection. Actual latency and throughput depend on the payload, network, server, and client.

The four gRPC call types
- Unary: One request and one response, such as looking up stock for one product.
- Server streaming: One request and a series of responses, such as subscribing to inventory changes.
- Client streaming: A series of requests followed by one response, such as sending a batch and receiving a summary.
- Bidirectional streaming: Both sides send a series of messages through the same call. Each side can send and receive independently.
When to choose gRPC or a REST-style API
Consider gRPC when you control both sides of an internal API, want a shared typed contract, or need ongoing streams. For a public API that customers will explore in a browser or call with basic HTTP tools, JSON over HTTP can be easier to adopt and debug. Browser JavaScript generally needs gRPC-Web or a gateway to use a native gRPC backend. Verify which kinds of streaming your gateway supports.
For comparison, learn how HTTP requests carry headers and JSON and how to read HTTP responses and status codes.

Before using gRPC in production
- Set a realistic deadline on client calls, and have server handlers stop work when they detect cancellation.
- Use TLS where appropriate, authenticate callers, and enforce authorization in the service. Retries require particular care for operations that write data.
- Treat the schema as a shared contract. Reserve deleted field numbers, test older clients against the new service, and check HTTP/2 support through proxies and load balancers.
The gRPC core concepts guide explains the four call types and how deadlines, metadata, and statuses fit into a call.
Reader Comments 0
Sign in with email or Google to join the discussion.