Features
- Protocol Buffers for efficient binary serialization
- HTTP/2 with multiplexing and bidirectional streaming
- Code generation for 10+ programming languages
- Built-in load balancing, tracing, and health checking
Pros
- 10x more efficient than JSON-based REST for large payloads
- Strongly typed contracts with code generation
- Bidirectional streaming for real-time communication
Cons
- Not browser-native (requires gRPC-Web proxy)
- Protobuf schemas are less human-readable than JSON
- More complex toolchain setup than REST
Overview
gRPC is a high-performance Remote Procedure Call (RPC) framework developed by Google. It uses Protocol Buffers (protobuf) as its interface definition language and serialization format, delivering significantly better performance than JSON-based APIs through binary encoding and HTTP/2 transport.
gRPC supports four communication patterns: unary (request-response), server streaming, client streaming, and bidirectional streaming. This makes it ideal for microservice communication, real-time systems, and any scenario where efficiency and strong contracts between services matter.
When to Use
gRPC is the right choice for service-to-service communication in microservice architectures, when low latency and high throughput are critical, or when you need streaming capabilities. For browser-facing APIs, REST or GraphQL is generally more practical.
Getting Started
// hello.proto
syntax = "proto3";
service Greeter {
rpc SayHello (HelloRequest) returns (HelloReply);
}
message HelloRequest { string name = 1; }
message HelloReply { string message = 1; }
# Generate code from proto file
protoc --js_out=. --grpc-web_out=. hello.proto