gRPC 101: The Simplest Guide You Will Ever Read

Ahmet Özlü
3 min readMay 30, 2021
gRPC — A high performance, open source universal RPC framework

In last years, projects are mainly developed with “microservice architecture”. Since smaller things are much easier to handle, microservices look perfect to develop big and complex projects in a faster and more efficient way.

In the beginning, REST architecture were used to develop microservices but was it perfect enough? The answer is no because there are some points, which are about speed and efficiency, can be improved. Then, gRPC framework has come and it has been a game-changer!

Microservice architecture is a distinctive method of developing software systems that tries to focus on building single-function modules with well-defined interfaces and operations.

What is gRPC?

gRPC is a modern open source high performance Remote Procedure Call (RPC) framework that can run in any environment.

An RPC library and framework. gRPC is a modern, open source, high-​performance remote procedure call (RPC) framework that can run anywhere.

Why gRPC?

It can efficiently connect services in and across data centers with pluggable support for load balancing, tracing, health checking and authentication. It is also applicable in last mile of distributed computing to connect devices, mobile applications and browsers to backend services.

  • Simple service definition: Define your service using Protocol Buffers, a powerful binary serialization toolset and language.
  • Start quickly and scale: Install runtime and dev environments with a single line and also scale to millions of RPCs per second with the framework.
  • Works across languages and platforms: Automatically generate idiomatic client and server stubs for your service in a variety of languages and platforms.
  • Bi-directional streaming and integrated auth: Bi-directional streaming and fully integrated pluggable authentication with HTTP/2-based transport.

Protocol Buffers or Proto

Protocol buffers are Google’s language-neutral, platform-neutral, extensible mechanism for serializing structured data — think XML, but smaller, faster, and simpler. You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages.

gRPC vs REST

gRPC is roughly 7 times faster than REST when receiving data & roughly 10 times faster than REST when sending data for this specific payload. This is mainly due to the tight packing of the Protocol Buffers and the use of HTTP/2 by gRPC.

gRPC vs REST

Disadvantages of gRPC

gRPC looks magical so far but there are some disadvantages of it unfortunately.

  • Lack of consistent error handling
  • Lack of developer tooling
  • Lack of infrastructure and monitoring support outside of Google Kubernetes Engine (GKE)
  • Limited insight into common practices
  • Lack of edge caching
  • Lack of support for additional content types

Conclusion

To conclude, REST has been around for 20 years and gRPC is not a replacement for REST. gRPC APIs can offer huge performance improvements and reduced response time as compared to REST APIs, but which approach to choose boils down to what fits your particular use case. You learnt about gRPC basics and you’ll learn how to develop your first gRPC project using python in next post! Stay tuned..

--

--

Ahmet Özlü

I am a big fan of Real Madrid CF and I love computer science!