DEV Community

loading...

My personal note on gRPC

Daiki Kudo
Rails, Python data analysis
・1 min read

Basic Concepts

  • gRPC is a rpc(protocol) framework.
  • Protocol Buffer is serialization mechanism supported by
    • IDL(Interface Definition Language) to write .proto file(scheme file) with
    • protoc(protocol buffer compiler) which can autogenerate client code & server code
    • Libraries which is used with afformentioned autogenerated scripts

Steps to use gRPC

  1. Write .proto file
    • with IDL
  2. Autogenerate client code & server code with $grpc-gen-grpc (, which is protoc command for ruby). This creates 2 files, which are
    • xxx_pb.rb(Request class and Response class are defined)
    • xxx_services_pb.rb(Service class and Stub class are defined)
  3. Implement server script (Server class should implemented here)&client script (which uses Stub class)` and boot them.

Technologies behind gRPC

Protocol Buffers

  • As is mentinoned, this is composed of lang + compiler + libraries.
  • For ruby, compiler command is protoc-gen-grpc which provides:
    • plugin to autogenerate message class
    • plugin to autogenerate service class
  • Its binary format is compact and quickly (de)serializable.

HTTP/2

  • Stems from SPDY from Google. Transport is totally updated from HTTP/1.1
  • Main functionalities are:
    • Multiplexing(多重化) which enables parallel responding (by multiple streams).
    • Header Compression(ヘッダ圧縮) by HPACK. (Originally in HTTP/1, header was 500-800 bytes)

References

Discussion (0)