19

gRPC is a "general RPC framework" which uses ProtoBuffer to serialize and deserialize while the net/rpc package seems could do "nearly" the same thing with encoding/gob and both are under the umbrella of Google.
So what's the difference between them? What pros and cons dose choosing one of them have?

lfree
  • 1,880
  • 3
  • 24
  • 39

1 Answers1

15

Well, you have said it yourself. 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. Also you don't need to learn the syntax of Protobuf to create your own services.

But, Protobuf is much faster than REST. It is a much more convenient way to communicate with the downside of the learning curve of the Protobuf syntax. Also, you can use Protobuf to generate the codebase in more languages than simply Go. So if you have some kind of service in Java, you can use Protobuf to generate RPC calls between them easily while if you use the net/rpc package you'll have to implement them twice (once in Go and once in Java)

In general, I will use Protobuf to nearly all. This gives you confidence to use it at more large scale or complex projects.

MaC
  • 529
  • 7
  • 14
  • 6
    I don't think "Protobuf uses RPC". Protobuf may be used to implement RPC. It may also be used for other messaging or serialization purposes. – asynchronos Aug 19 '16 at 16:42
  • You are right, I meant in this specific context "Protobuf uses RPC in the context of gRPC". I have edit it to make it more clear just in case – MaC Aug 19 '16 at 21:22
  • 5
    Please please don't say "REST" when you wanted to say "a series of HTTP requests". ReST is a methodology which per se has no bearing on HTTP. – kostix Aug 19 '16 at 23:31
  • @MaC So the main difference between gRPC and net/rpc to implement a RPC component is that gRPC can support multiple languages? – lfree Aug 21 '16 at 08:57
  • **Mainly** yes. As far as I know gRPC wants to support JSON, XML and others in the future and has some features like the balancer that are still experimental. Think of it as a high level layer over net/rpc that can ease some of your tasks. – MaC Aug 21 '16 at 11:30
  • Well explained i will need to use grpc in my case . – I.Tyger Mar 19 '19 at 09:01
  • What I got is that `gob` does not have the `protoc` compilation step and is `golang` restricted but what about performance... is `gob` faster than `gRPC` ? – ton Apr 09 '21 at 21:14