Hello, Today I am going to talk about gRPC.
A high performance, open source universal RPC framework by google.
Now its part of the Cloud Foundation (CNCF)
Let's Understand RPC!
An RPC is a Remote Procedure Call. Google introduce gRPC, But Common Object Request Broker Architecture (CORBA) had RPC before!
In this above example, you see right side a server code written any other language and left client code calling server function. Okay, Lets consider server written in python we want to call this function from another language, what we will do we simply create a rest api then call that api using other language client. Now think 🤔 is not it cool? if we could call that function nativity like we call functions. I know that will be amazing using RPC we can do that easily.
Here is an another example from grpc.io website. You can see gRPC server code is written in C++, and gRPC Stubs Or Clients are written in different languages. Here as Stubs they are using Ruby and Java Android client. Do not worry I will share complete example end of the season.
When we choose gRPC?
- When we wants to build microservices
- Wants to communicate between cross-languages services
- Planning to build distributed services
- Needs client & server streaming
- Needs Http/2 based transport protocol
gRPC vs REST
REST
REST uses HTTP/1.1 protocol through the JSON or XML messaging format. Common http verbs like {GET, POST, PUT, DELETE etc}
gRPC
gRPC uses HTTP/2 protocol through Protocol buffer. Methods {unary, server-streaming, client-streaming and bi-directional call}. It offers language independence support 11 programming languages.
gRPC methods/operations
What is Protocol Buffer
- Protocol buffer are language language-neutral, platform-neutral extensible mechanism for serializing structured data
- Code generated for any language
- Very convenient for transporting a lot of data
- Data is binary and efficiently serialized (small payloads)
- Support Java, Go, Python, NodeJs, Objective-C, C++ and more with proto3 language version.
gRPC vs Rest
Sample gRPC Based Micro-service Architecture
Complete gRPC server & clients check that Demo Codebase
Congratulations
I hope we learn something exciting about gRPC framework. Thanks for time & passion. Feel free to ask me anything.
Say Hi to me on Twitter, Linkedin, and Medium where I keep on sharing interesting updates.
Top comments (0)