In conversation with Google’s gRPC | Part1

  • Buying-Service where users buy things right.
  • It may connect to another micro-service written in another language called Promotional-Service.
  • There may also be a Delivery-Service micro-service that will provide you with the service.
  • Next, we have a User-Service which talks about the users and their journey.
  • Say, we have a function named createUser hosted @ server side.
  • Also, we have a function-call to createUser in client code.
  • Here, we have a “Greeting” message.
  • We get a predefined “GreetingRequest” message and similarly a “GreetingResponse”.
  • At very bottom, we have a “GreetingService” that accepts GreetingRequest and returns the GreetingResponse.
  • Unary → This is how a traditional API looks like with usual request/response. The client shall send one message to the server and would receive one response from the server. Unary RPC calls are well suited, when data to be transferred is small.
  • Server/Client/Bidirectional Streaming → With HTTP/2, we have streaming capabilities i.e. server and client can push multiple messages as part of one request. We can use these streaming RPC calls , if we have scaling and optimisation issues.
  • REST shall be using JSON as data-transfer standard which would be slower, bigger and text-based while gRPC uses the protobuf as data-transfer standard which are smaller and faster in nature.
  • REST uses the HTTP/1.1 while gRPC uses the HTTP/2 which is lot more faster and efficient.
  • REST only supports Client to server calls while gRPC supports bidirectional and async calls as well.
  • REST only supports request/response while gRPC supports streaming capabilities as well.
  • REST is purely Resource-oriented while gRPC is purely API oriented with free-design.
  • REST supports auto-code-generation using swagger and openAPI as 2nd class citizens while gRPC supports auto-code-generation using prtobuf as 1st class citizens.
  • REST is Verbs based and thus we have to basic plumbing ourselves while gRPC is RPC based i.e. we can invoke the functions at server easily.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store