跪拜 Guibai
← All articles
Backend

HTTP/2 and Protobuf Are Pushing gRPC Past REST for Internal Services

By 苏三说技术 ·
Read original on juejin.cn ↗ Google Translate ↗ Alt translation

Internal service calls that saturate CPU on JSON serialization and HTTP/1.1 handshakes can triple throughput on the same hardware by switching to gRPC. With Spring Boot 4.1.0 providing first-class auto-configuration, the integration cost has dropped to the point where not evaluating gRPC for high-frequency internal paths is a deliberate performance concession.

Summary

A team running a Spring Cloud microservices stack hit a wall at 800 QPS: CPU was saturated by JSON serialization and HTTP/1.1 connection churn, not business logic. Swapping two high-frequency internal services to gRPC tripled QPS and dropped response times to one-third of the original, with no other changes. The gains come from two layers. HTTP/2 multiplexes hundreds of requests over a single TCP connection, eliminating per-request handshake overhead. Protobuf transmits field numbers instead of field names, shrinking payloads by 60–80% and parsing 3–5× faster than JSON text parsing.

Spring Boot 4.1.0 now ships official gRPC auto-configuration, replacing the patchwork of third-party starters. A service annotated with @GrpcService is discovered and mounted automatically; clients inject stubs via @GrpcClient with channel targets defined in application.yml. The release also adds @GrpcAdvice for centralized exception handling and renames several configuration properties from the 1.0.x spring-grpc era.

gRPC is not a wholesale REST replacement. Browsers still need a gRPC-Web proxy, debugging binary payloads requires tools like grpcurl, and Kubernetes load balancing must account for long-lived connections. For external APIs and simple CRUD apps, REST remains the pragmatic default. For internal service meshes, multi-language teams, and streaming workloads, the performance gap is now wide enough that skipping gRPC leaves throughput on the table.

Takeaways
Replacing REST+JSON with gRPC+Protobuf on two high-frequency internal services tripled QPS and cut response time to one-third in a real Spring Cloud workload.
HTTP/2 multiplexing handles hundreds of concurrent requests over one TCP connection, avoiding per-request three-way handshakes.
Protobuf binary serialization reduces payload size by 60–80% and runs 3–5× faster than JSON text parsing.
Spring Boot 4.1.0 provides official gRPC starters and auto-configuration: @GrpcService for servers, @GrpcClient for stubs, and @GrpcAdvice for unified exception handling.
Configuration property names changed between spring-grpc 1.0.x and Spring Boot 4.1; channel address becomes target, and server address splits into separate address and port keys.
gRPC supports four communication patterns: unary, server streaming, client streaming, and bidirectional streaming.
Browser clients still require a gRPC-Web proxy, and Kubernetes load balancing needs headless services or a service mesh to handle long-lived gRPC connections.
Conclusions

gRPC's adoption curve is being pulled by two forces at once: the raw performance gap versus REST is widening as traffic scales, while Spring Boot's official support removes the integration friction that previously kept teams on REST.

The performance numbers cited—107% higher throughput, 48% lower latency—are not marginal improvements. They represent the difference between a service that survives a traffic spike and one that falls over because the wire format ate the CPU budget.

gRPC's strongest pitch is not universal replacement but surgical application: swap the hottest internal paths and leave external APIs on REST. The browser incompatibility and debugging friction make wholesale migration a poor trade-off for most orgs.

Concepts & terms
HTTP/2 Multiplexing
A single TCP connection carries multiple concurrent request-response streams as interleaved binary frames, eliminating the per-request connection setup cost of HTTP/1.1.
Protocol Buffers (Protobuf)
A binary serialization format where data structures are defined in .proto files and compiled to language-specific classes. Fields are identified by numeric tags rather than names, producing payloads 60–80% smaller than equivalent JSON.
gRPC Streaming Modes
Four communication patterns beyond simple request-response: server streaming (one request, many responses), client streaming (many requests, one response), and bidirectional streaming (both sides send independently).
gRPC-Web
A JavaScript client library and proxy that lets browser applications call gRPC services, since browsers lack the low-level HTTP/2 frame control that native gRPC requires.
Source: juejin.cn ↗ Google Translate ↗ Backup ↗