protobuf vs gRPC

Protocol buffers is (are?) an Interface Definition Language and serialization library:

  • You define your data structures in its IDL i.e. describe the data objects you want to use
  • It provides routines to translate your data objects to and from binary, e.g. for writing/reading data from disk

gRPC uses the same IDL but adds syntax “rpc” which lets you define Remote Procedure Call method signatures using the Protobuf data structures as data types:

  • You define your data structures
  • You add your rpc method definitions
  • It provides code to serve up and call the method signatures over a network
  • You can still serialize the data objects manually with Protobuf if you need to

In answer to the questions:

  1. gRPC works at layers 5, 6 and 7. Protobuf works at layer 6.
  2. When you say “message transfer”, Protobuf is not concerned with the transfer itself. It only works at either end of any data transfer, turning bytes into objects
  3. Using gRPC by default means you are using Protobuf. You could write your own client that uses Protobuf but not gRPC to interoperate with gRPC, or plugin other serializers to gRPC – but using gRPC would be easier
  4. True
  5. Yes you can

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)