What is gRPC

Shanaka Sandanayaka
3 min readAug 30, 2020

--

Recently, I have heard about this Buzz word alongside the API management. Therefore the past few days, I have read about this and it is quite an interesting thing to discuss.

Before discussing what is gRPC, let’s try to discuss what is the problems encountering with the modern application development using the Microservices. Since the Microservices are written in multiple languages, It needs to agree on a one single API contract to communicate in between. Designing an API is not that easy. It bringing up so many challenges such as follows.

  • Determine the data model.
  • Need to think about payload format whether it JSON, XML, or something binary?
  • Need to think about the endpoint structure.
  • Invocation and error handling.
  • Authentication whether it is Basic auth, Oauth, JWT…etc.
  • Communication efficiently.
  • Scalability of the API’s

Let’s imagine that if there is a framework addressing all of the above concerns and only you have to implement the core logic. Here comes the gRPC.

What is gRPC ?

It is a high performing open-source framework developed by Google. Then there is a question what is RPC? RPC, Remote procedure call. It is simple as follows.

  • Execute the function of another computer. Without developer explicitly coding regarding the network interaction.
  • In code, It simply looks like calling a function.
  • The 2 implementations are language-independent, So the client program might use java and the server is using python.

The RPC is not a modern concept, It was already addressed with the frameworks like CORBA. but in gRPC, it’s implemented very clearly and conveniently solved a lot of problems encountered previously.

How gRPC works.

  • The client generated a stub with all the functions provided by the server.
  • The underlying gRPC framework is responsible for exchanging information over the network.
  • Since the client and server used only the stubs to communicate with each other, It only necessary to implement the core logic only.

gRPC vs REST

You might we already have REST API’s which is much more popular and have much more resources. Let’s discuss some of the advantages of gRPC over the REST API’s

When gRPC is more suitable

  • In Microservices, Since low latency in of the calls.
  • Point to point real time communicating systems, Due to the support of bi-directional streaming support.
  • Network constrained environments such as mobile apps which is having a limited bandwidth.

Hope this gives a brief understanding of the gRPC and in future article lets deep into further and try to code something with gRPC. For more information please check the gRPC official web.

--

--