Our microservices communicate via REST with JSON. It works, but JSON serialization is slow, there’s no schema, and streaming is a hack. gRPC solves all three problems.
What is gRPC¶
An RPC framework from Google. Protocol Buffers for serialization (binary, compact, typed) and HTTP/2 as transport (multiplexing, streaming).
syntax = "proto3";
service OrderService {
rpc CreateOrder (CreateOrderRequest) returns (Order);
rpc StreamUpdates (GetOrderRequest) returns (stream OrderUpdate);
}
message Order {
string id = 1;
string status = 2;
}
Performance difference¶
- Serialization: protobuf 3-5x faster than JSON
- Payload: protobuf 2-3x smaller
- Latency: gRPC ~30% lower thanks to HTTP/2
- Streaming: gRPC native
When to use gRPC, when REST¶
gRPC: internal service-to-service, high-throughput streaming. REST: public APIs, browsers, third parties. Envoy can handle gRPC-JSON transcoding at system boundaries.
gRPC is ideal for internal microservices¶
For public APIs use REST, for internal communication use gRPC — typed contracts, high performance, and native streaming. We’re migrating gradually.
Need help with implementation?
Our experts can help with design, implementation, and operations. From architecture to production.
Contact us