For years, REST has been the de facto standard for providers when deciding how to design their API. Our directory shows that it is by far the most popular architectural style in use today. In recent years, GraphQL has garnered a lot of attention as an alternative architectural style that offers a number of advantages over REST in certain use cases. Another alternative, one that has been less trendy but may prove to be just as important, is gRPC.
gRPC is an open-source remote procedure call framework (RPC). It runs on the HTTP/2 protocol and is meant to enable client and server applications to communicate transparently. A recent article by James Newton-King discusses gRPC’s strengths and weaknesses, and when gRPC APIs are a good choice to build your apps.
One of gRPC’s strengths is in its performance. Messages are serialized using Protobuf, a binary message format that results in smaller message payloads. Another major benefit comes from gRPC’s use of HTTP/2, an open protocol designed for real-time communication streams. HTTP/2 can be leveraged to create faster mobile experiences that require less battery power from mobile devices, making gRPC an attractive option for mobile developers.
On the other hand, gRPC is not supported by major web browsers. While HTTP/2 is supported by most modern browsers, none of them provide the level of control required over web requests to support a gRPC client. Another downside is that by default gRPC messages are encoded with Protobuf, a binary format that isn’t human-readable.
Newton-King suggests that gRPC is best suited for use with lightweight microservices where efficiency is critical due to its lightweight message format, and point-to-point real-time communication due to gRPC’s excellent support for bidirectional streaming. gRPC is also good for multi-language environments as its tooling supports all major development languages.
In the end, gRPC isn’t a direct replacement for REST, but with more use cases requiring the performance benefits it offers, developers would do well to understand how best to use it.