Go and gRPC have become a popular choice for microservices of late. gRPC is an efficient over the wire communication protocol. Built on top of http/2 and protobuf (in theory other serialization protocols can also be supported), this is supposed to be faster, with lesser network overhead and an efficient protocol.
Http 2 is the next version of http protocol(http 1.1 is the most commonly used current version). Few points to note about http 2.0
If http 2.0 is so good, why does not everyone use it?
Protobuf is a messaging protocol for over the wire communication. Being a binary transfer protocol, it packs the data in a compact format for efficient and faster data transfer. The client library to work with protobuf is available in several languages. Golang has a native support of protobuf.
Long back, XML was kind of default serialization format and increasing popularity of Java could be attributed to its rise.
While xml was easy to read/write/manipulate for both human and mahcine, yet it was too verbose and for a larger payload it had a high overhead.
With javascript’s rise in popularity another cool serialization format started becoming popular, i.e. JSON. JSON was much smaller in size and still completely readable by human and was less verbose.
Although JSON is quite readable, but it seems the specs are not very clear and there are times when different libraries would interpret it differently. Parsing JSON seems to be much more CPU intensive as well. The default JSON parser in golang actually seems to be on a slower side.
Since, bigger payload was leading to higher network transfer cost, one alternative to that was compressing the data before transferring and decompressing it at the other end. This technique is quite popular and infact most of the modern browsers support gzip compression and its enabled by default which helps in reducing the payload size.so with json/xml based services, typically compression is enabled which reduces the payload size to a great extent.
For a more efficient packing of data, the need of better options arose. Focused on the core needs instead of being a generic serlization solutions, many companies developed their own protocols which had less metadata attached, and thus reducing the payload size.
Protobuff is one such option. It was developed within Google and later opensourced. Thrift is another which was developed by Facebook and later opensourced.
Few questions to ask
References:
https://cdn-1.wp.nginx.com/wp-content/uploads/2015/09/NGINX_HTTP2_White_Paper_v4.pdf
HTTP/2 Frequently Asked Questions_These are Frequently Asked Questions about HTTP/2._http2.github.io
grpc / Guides_A high-performance, open-source universal RPC framework. Client applications can directly call methods on a server…_grpc.io
Parsing JSON is a Minefield | Hacker News_Third, parsing everything is a minefield, including HTML. We as a community invest a lot of collective effort in…_news.ycombinator.com