Is gRPC(HTTP/2) faster than REST with HTTP/2?

前端 未结 2 710
独厮守ぢ
独厮守ぢ 2021-01-29 18:21

The goal is to introduce a transport and application layer protocol that is better in its latency and network throughput. Currently, the applic

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-29 19:14

    I am not an expert on this by any means and I have no data to back any of this up.

    The "binary feature" you're talking about is the binary representation of HTTP/2 frames. The content itself (a JSON payload) will still be UTF-8. You can compress that JSON and set Content-Encoding: gzip, just like HTTP/1.

    But gRPC does gzip compression as well. So really, we're talking about the difference between gzip-compressed JSON vs gzip-compressed protobufs.

    As you can imagine, compressed protobufs should beat compressed JSON in every way, or else protobufs have failed at their goal.

    Besides the ubiquity of JSON vs protobufs, the only downside I can see to using protobufs is that you need the .proto to decode them, say in a tcpdump situation.

提交回复
热议问题