Introduction to gRPCs

aditya goel
6 min readFeb 18, 2023

Question: What is gRPC ?

Answer → gRPC is an open-source remote procedure call framework created by Google in 2016. It was a re-write of their internal RPC Infrastructure, that they used for years.

Question: What is an RPC ?

Answer → A gRPC is an popular implementation of RPC.

  • A Local-Procedure Call is a function call within a process to execute some code.
  • A Remote-Procedure Call enables one machine to invoke some code on another machine, as if it is local function call, from a User’s prospective.

Question: Who all uses gRPC as preferred choice of communication ?

Answer → Many Organisations have adopted gRPC as their preferred RPC mechanism to connect a large number of micro-services, running within and across data-centres.

Question: What makes gRPC so popular ?

Answer → There are many good reasons that gRPC is so popular :-

Reason #1.) gRPC has a thriving developer eco-system. It makes it very easy to develop production quality and type-safe APIs, that scale well.

Reason #2.) gRPC is high-performance out of the box.

Question: What is the core of the gRPC based eco-system ?

Answer → The core of this eco-system is the use of Protocol-Buffers, as its Data-Interchange format. Protocol-Buffer is a Language-agnostic and platform-agnostic mechanism for encoding structured data.

Question: What is the connection between gRPC and Protocol-Buffers ?

Answer → gRPC uses Protocol-Buffers, to encode and send data over the wire by default. While the gRPC could also support other encoding formats like JSON, Protocol-Buffers provides several advantages that make it encoding format of choice for gRPCs.

Question: Explain little bit more details about the Protocol-Buffers ?

Answer → Please find below, some key points of working with ProtoBuf :-

1.) Protocol-Buffers supports strongly-typed schema definitions. The structure of the data over the wire is defined in a proto file.

2.) Protocol-Buffers provide strong tooling support, to turn the schema defined in a proto-file into data-access-classes, for all popular programming languages.

3.) A gRPC service is also defined in a proto file, by specifying RPC method parameters and return types.

4.) The same tooling is used to generate the grpc-Client and gRPC-Server code, using the proto file. Developers uses these generated classes :-

  • In the Client, to make RPC calls.
  • In the Server, to fulfil the RPC requests.

Question: What is the advantage offered by Protocol-Buffers supporting so many Programming Languages

Answer → By supporting so many Programming Languages, the client and server can independently choose the PL and eco-system best suited for their own particular use-cases. This is traditionally not the case with most of the RPC-Frameworks.

Question: Why gRPC is highly performant ?

Answer → There are primarily two factors for gRPCs having high performance :-

Reason #1.) Protocol-Buffers is a very efficient binary encoding format. It’s much faster than JSONs.

Reason #2.) gRPC is built on top of Http/2, to provide a high-performance foundation at scale. It allows multiple stream of messages, over a single long-lived TCP-Connection.

Question: What is the primary benefit of using http/2 ?

Answer → There are many benefits of using HTTP/2, but the major one is Multiplexing, through the help of which, Http/2 allows the gRPC framework to handle many concurrent RPC calls, over a small number of TCP-connections between Client & Server.

Question: How does gRPC works ?

Answer → Let’s take our earlier example :-

  • Client → The OrderService is the gRPC client.
  • Server → The PaymentService is the gRPC server.

Step #1.) When the OrderService makes a gRPC call to the Payment-Service, it invokes the client-code generated by gRPC tooling at build time. This generated client-code is called as Client-Stub.

Step #2.) gRPC encodes the data passed to the Client-Stub into the Protocol-Buffers.

Step #3.) gRPC then sends the encoded-data to the Low-level Transport Layer.

Step #4.) gRPC sends the data over the network, as a stream of Http/2 data-frames. Because of Binary-Encoding and Network Optimisation, gRPC is said to be 5 times faster than JSONs.

Step #5.) The PaymentService receives the packets from Network, decodes-them and invokes the server-application.

Step #6.) The result this returned from the Server-Application, gets encoded into Protocol-Buffers and sent back to the Transport Layer.

Step #7.) The OrderService receives the packets, decodes them and sends the result to the Client-Application.

Question: Why there is no wide-spread reach of gRPC ?

Answer → One reason is that, gRPCs relies on lower-level access to HTTP/2 primitives.

No Browser currently provides the level of control, required over web requests to support a gRPC Client.

Question: Is it possible to make gRPC calls from a Browser ?

Answer → Yes, it is very much possible, with the help of Proxies. This technology is called as gRPC-Web.

Question: When should we make use of gRPCs ?

Answer → gRPCs is the inter-service communication mechanism of choice between the micro-services in a Data-Centre.

  • It’s broad support for many Programming Languages allows services to choose their own language and developer ecosystems well suited for their own use-cases.
  • We also see increasing use of gRPCs in the native mobile clients. It’s efficiency and performance makes a lot of sense in the energy and bandwidth-constrained environments like that of Mobile-Devices.

That’s all in this blog. If you liked reading it, do clap on this page. We shall see you in next document.

References :-



aditya goel

Software Engineer for Big Data distributed systems