Building Microservices with
gRPC
Sathya
Software Developer @ MoneySmart
REST APIs
● Well defined HTTP verbs
● JSON objects can be consumed by JavaScript easily.
● cURL friendly.
● Matured HTTP client libraries support in major languages.
Is it suitable for Microservices?
Not everything is a resource
Calculator Service
Manual Stub Code
Other problems
● Maintenance of the API documentation.
● JSON is text based which added unnecessary burden to the performance when serializing and
deserializing data.
gRPC
gRPC
● High performance RPC system.
● Uses HTTP/2 for transport.
● Uses ProtoBuf as Message Format.
● Supports different modes such as unary and bidirectional streaming.
● Ability to Cancel or Timeout requests.
ProtoBuf
● Mechanism for serializing structured data
● Binary Message Format
● For describing both service interface and message
structure
Advantages:
1. Better Performance
2. Easy to read Service and Message Definition
3. Able to generate Stub Classes Programmatically
Benefits of gRPC
1. Proto files itself act as the service documentation.
2. Automatic code generation for stubs by using proto compilers.
3. Better Performance by using HTTP/2 for transport and protobuf for serializing
Writing gRPC service
Steps:
1. Write Service Definition in Proto file format.
2. Generate Client / Server code using proto compiler.
3. Implement the Server by extending the generated server code.
4. Implement the Client by calling methods using the generated Client Stub.
Questions???
Useful Links
● https://grpc.io/
● https://developers.google.com/protocol-buffers/docs/proto3
● https://github.com/bigcommerce/gruf
● http://avi.im/grpc-errors/#ruby
● https://github.com/avinassh/grpc-errors
www.moneysmart.co/jobs

Building microservices with grpc

  • 1.
  • 2.
    REST APIs ● Welldefined HTTP verbs ● JSON objects can be consumed by JavaScript easily. ● cURL friendly. ● Matured HTTP client libraries support in major languages.
  • 3.
    Is it suitablefor Microservices?
  • 4.
    Not everything isa resource Calculator Service
  • 5.
  • 6.
    Other problems ● Maintenanceof the API documentation. ● JSON is text based which added unnecessary burden to the performance when serializing and deserializing data.
  • 7.
  • 8.
    gRPC ● High performanceRPC system. ● Uses HTTP/2 for transport. ● Uses ProtoBuf as Message Format. ● Supports different modes such as unary and bidirectional streaming. ● Ability to Cancel or Timeout requests.
  • 9.
    ProtoBuf ● Mechanism forserializing structured data ● Binary Message Format ● For describing both service interface and message structure Advantages: 1. Better Performance 2. Easy to read Service and Message Definition 3. Able to generate Stub Classes Programmatically
  • 10.
    Benefits of gRPC 1.Proto files itself act as the service documentation. 2. Automatic code generation for stubs by using proto compilers. 3. Better Performance by using HTTP/2 for transport and protobuf for serializing
  • 11.
    Writing gRPC service Steps: 1.Write Service Definition in Proto file format. 2. Generate Client / Server code using proto compiler. 3. Implement the Server by extending the generated server code. 4. Implement the Client by calling methods using the generated Client Stub.
  • 12.
  • 13.
    Useful Links ● https://grpc.io/ ●https://developers.google.com/protocol-buffers/docs/proto3 ● https://github.com/bigcommerce/gruf ● http://avi.im/grpc-errors/#ruby ● https://github.com/avinassh/grpc-errors
  • 14.