Basic Concepts
-
gRPCis a rpc(protocol) framework. -
Protocol Bufferis 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
- Write
.proto file- with IDL
- Autogenerate client code & server code with
$grpc-gen-grpc(, which isprotoccommand for ruby). This creates 2 files, which are-
xxx_pb.rb(Request classandResponse classare defined) -
xxx_services_pb.rb(Service classandStub classare defined)
-
- Implement
server script(Server classshould 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-grpcwhich 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)
Top comments (0)