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.
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
Create your free account to unlock your custom reading experience.