Google Remote Procedure Calls (gRPC) is an open source Remote Procedure Call (RPC) system used to provide communication between microservices. gRPC is based on the HTTP/2 protocol. It also provides various features such as authentication, blocking or non-blocking bindings, bidirectional streaming and flow control, and cancellation and timeouts. gRPC supports various programming languages such as C++, C#, Dart, Go, Java, Node.js, Objective-C, PHP, Python, and Ruby. It provides cross-platform clients and server bindings for any language.
Google started the gRPC protocol to communicate between modules of a distributed microservice-based application within the same intranet or on the same server, thereby reducing HTTP REST calls. In gRPC-based communication, the service client directly calls the methods of the server application on a different machine. This is similar to local method calls for the same application on the same server.
We have to define the methods in a service. These methods can be called remotely using their parameters and return types, as in any RPC system. Similarly, on the server side, we have to implement the same methods. We also have to run a gRPC server to handle all the requests coming from clients. The client has a stub implementation, just as the server has all the methods and their implementations.
The following diagram illustrates the gRPC system:
As you can see in the preceding diagram, the gRPC client and server are talking to each other. The client gRPC and the server gRPC have different languages. Therefore, a gRPC-based protocol supports various environments and languages. You can learn more about the gRPC system at https://grpc.io/.
In the following section, we'll have a look at another system used to provide inter-service communication between microservices.