Reputation: 396
I read that gRPC is more performant than traditional HTTP APIs due to more compact serializing with Protocol Buffers. The other performance claim is that unlike HTTP/1.1 JSON APIs, it supports pipelining.
As I currently understand, the pipelining of multiple connections over a single HTTP connection is done by HTTP/2 and not by gRPC. So, apart from the from the more efficient data serializing format, is there actually a performance benefit for gRPC compared to JSON over HTTP/2?
Upvotes: 1
Views: 3740
Reputation: 129065
There are multiple aspects here.
There are many improvements in HTTP/2 over HTTP/1.1, but there are also disadvantages for some use cases. Some examples of improvments:
Authorization: Bearer <JWT-token>
in consecutive API-requests.This may have an effect on payload size but serialization and deserialization performance is probably more important. Another important aspect is developer tooling and productivity.
Protocol Buffers, used by gRPC is not the only efficient binary payload format. There are many alternatives, e.g. FlatBuffers, a zero-copy format, designed after experience with Protocol Buffers. Another binary format, mainly for smaller payload (not serialization performance) is Avro. Avro format may have a benefit in evolvability of the payload format (see e.g. Designing Data-Intensive Applications).
See e.g. JSON vs Protocol Buffers vs FlatBuffers for a comparison.
gRPC is a higher protocol abstraction than purely using HTTP/2. Fewer details is left to the developer to take care of. In all, there are many aspects in the choice of HTTP/2+JSON vs gRPC, it all depends on what's the most important aspect for your use case.
Upvotes: 2