Microservices

Google Remote Procedure Calls gRPC

Google Remote Procedure Calls (gRPC) is an open source Remote Procedure Call (RPC) system used to provide communication between microservices. Google Remote Procedure Calls is based on the HTTP/2 protocol. It also provides various features such as authentication, blocking or nonblocking bindings, bidirectional streaming and flow control, and cancellation and timeouts.

The 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.

So, Google started gRPC protocol to communicate between modules of a distributed microservices based application within the same intranet or within the same server, so it reduces HTTP REST calls. In the gRPC based communication, the service client directly calls methods of the server application on a different machine as similar to local method calls for the same application on the same server.

We have to define the methods in service and these methods can be called remotely with using their parameters and return types as we do in any RPC system. Similarly, on the server side, we have to implement that interface. Also, we have to run a gRPC server to handle all requests coming from clients. The client has a stub implementation same as the server has all methods and its implementations.

Google Remote Procedure Calls

The following diagram illustrates the gRPC system:

gRPC

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 gRPC a client application can directly call methods on a server application on a different machine as if it was a local object, making it easier for you to create distributed applications and services. As in many RPC systems, gRPC is based around the idea of defining a service, specifying the methods that can be called remotely with their parameters and return types. On the server side, the server implements this interface and runs a gRPC server to handle client calls. On the client side, the client has a stub (referred to as just a client in some languages) that provides the same methods as the server.

Learn with more details from here.

Previous
Next
Dinesh Rajput

Dinesh Rajput is the chief editor of a website Dineshonjava, a technical blog dedicated to the Spring and Java technologies. It has a series of articles related to Java technologies. Dinesh has been a Spring enthusiast since 2008 and is a Pivotal Certified Spring Professional, an author of a book Spring 5 Design Pattern, and a blogger. He has more than 10 years of experience with different aspects of Spring and Java design and development. His core expertise lies in the latest version of Spring Framework, Spring Boot, Spring Security, creating REST APIs, Microservice Architecture, Reactive Pattern, Spring AOP, Design Patterns, Struts, Hibernate, Web Services, Spring Batch, Cassandra, MongoDB, and Web Application Design and Architecture. He is currently working as a technology manager at a leading product and web development company. He worked as a developer and tech lead at the Bennett, Coleman & Co. Ltd and was the first developer in his previous company, Paytm. Dinesh is passionate about the latest Java technologies and loves to write technical blogs related to it. He is a very active member of the Java and Spring community on different forums. When it comes to the Spring Framework and Java, Dinesh tops the list!

Share
Published by
Dinesh Rajput

Recent Posts

Strategy Design PatternsĀ using Lambda

Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…

2 years ago

Decorator Pattern using Lambda

Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…

2 years ago

Delegating pattern using lambda

Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…

2 years ago

Spring Vs Django- Know The Difference Between The Two

Technology has emerged a lot in the last decade, and now we have artificial intelligence;…

2 years ago

TOP 20 MongoDB INTERVIEW QUESTIONS 2022

Managing a database is becoming increasingly complex now due to the vast amount of data…

2 years ago

Scheduler @Scheduled Annotation Spring Boot

Overview In this article, we will explore Spring Scheduler how we could use it by…

3 years ago