Performance Benchmarking: gRPC+Protobuf vs. HTTP+JSON

A performance benchmark comparing gRPC with Protocol Buffers against HTTP with JSON in Go revealed unexpected results. While gRPC is often favored for microservices due to Protocol Buffers' efficiency, this benchmark showed HTTP/1 significantly outperforming both gRPC and HTTP/2. The experiment, designed to isolate serialization and transport protocol performance by minimizing extraneous operations, used identical CreateUser endpoints for both stacks. The findings indicate that, on the tested local machine configuration (Go 1.22 on Apple M1 Pro), HTTP/1 delivered superior speed, followed by gRPC, with HTTP/2 (H2C) being the slowest. This challenges the common assumption that gRPC inherently provides higher performance for inter-service communication compared to HTTP-based solutions, though the article notes Protocol Buffers' structured format remains a benefit for internal services. The author cautions that results are specific to the implementation and environment, and real-world performance can vary.

AI Signal Decode

The benchmark focused on comparing data serialization and transport protocols by implementing identical CreateUser functionalities using gRPC with Protocol Buffers and HTTP with JSON. The setup deliberately excluded external factors like database calls or heavy computations, ensuring the performance metrics directly reflected the differences between gRPC/Protobuf and HTTP/JSON (over both HTTP/1 and HTTP/2). The use of Go for implementation and a local machine environment for testing provided a specific, though potentially not universally applicable, set of results.

Market implications suggest a need for re-evaluation of performance assumptions in microservice architectures. While gRPC and Protocol Buffers are often championed for their efficiency and structured data handling, this benchmark highlights that HTTP/1 can, in certain Go implementations, offer superior raw performance. This could influence technology choices for internal service communication where latency is critical, potentially leading developers to favor simpler HTTP/1 implementations if their specific use case benefits from its speed, despite gRPC's advanced features.

Technically, the benchmark reveals a known issue in Go where HTTP/2 (H2C) can be slower than HTTP/1. The fact that gRPC, which typically leverages HTTP/2, also underperformed HTTP/1 in this specific test warrants further investigation into the Go standard library's implementation of these protocols. The article provides sample Go code for both gRPC and HTTP services, along with the benchmarking setup, allowing for reproducibility and further experimentation by the community.

Moving forward, developers should exercise caution when relying solely on general performance claims. The author stresses the importance of conducting custom benchmarks tailored to specific use cases, languages, and hardware. Future investigations could explore performance differences across various programming languages, different HTTP/2 configurations, or the impact of varying payload sizes and network conditions on the observed results.