Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What the difference between JSON RPC with HTTP2 vs grpc?

I don't like tools that do many things at once. So GRPC seems to me overhead, it's like kubernetes. GRPC is the tool that combines actually two things: extended Protobuf (Service support) and HTTP2.

I read a lot of articles saying that using GRPC is awesome for performance. And there are two reasons

  • protobuf is used, it's smaller than json or xml.
  • GRPC uses HTTP2 for transport protocol

Here is main part: protobuf and HTTP2 are independent projects, tools, whatever. With that understanding i can say that GRPC is nothing but combining several different tools, like kubernetes combines docker and orchestration tools.

So my questions is: What's actual advantages of using GRPC vs HTTP2 with any payload (CSV, XML, JSON, etc).

Let's skip part about serialization because as i mentioned protobuf is independent library from grpc

like image 835
Alexander Kondaurov Avatar asked Nov 08 '19 13:11

Alexander Kondaurov


People also ask

What is difference between gRPC and RPC?

gRPC is a framework that uses RPC to communicate. RPC is not Protobuf but instead Protobuf can use RPC and gRPC is actually Protobuf over RPC. You don't need to use Protobuf to create RPC services within your app. This is a good idea if you are doing libraries/apps from small to medium size.

Does gRPC use http2?

gRPC is a Remote Procedure Call (RPC) framework that uses HTTP/2 as its transport medium. It is especially useful for managing communication between apps in a microservices cluster. For apps to serve gRPC traffic, every network hop between the client and app must use HTTP/2.

Can gRPC work with JSON?

grpc-gateway is another technology for creating RESTful JSON APIs from gRPC services. It uses the same . proto annotations to map HTTP concepts to gRPC services. grpc-gateway uses code generation to create a reverse-proxy server.

Is gRPC Faster Than REST API?

You just have to make calls to the server address, unlike gRPC, which requires the client setup. REST API still holds importance when the payload is small, and several clients simultaneously make a server call. As a result, gRPC is a lot faster than REST API in most cases.


1 Answers

As you pointed out, gRPC and Protobuf are often conflated. While, in the vast majority of cases, gRPC will be using protobuf as an IDL and HTTP/2 as the transport, this is not always the case.

So then, what value does gRPC provide on its own? For starters, it provides battle-tested implementations of each of those transports, along with first class support for the protobuf IDL. Integrating these things is not trivial. gRPC packages all of them into one nice pluggable box so you don't have to do the legwork.

It also provides you with functionality that HTTP/2 on its own does not. Pluggable authorization/authentication, distributed tracing instrumentation, debugging utilities, look-aside load balancing (including upcoming support for the xDS protocol), and more are provided.

like image 174
Richard Belleville Avatar answered Oct 05 '22 05:10

Richard Belleville