grpc pointers - pogo420/grpc_learning GitHub Wiki

What is grpc?

  • Framework built over http2 and protobuf binary messages.
  • Unlike rest architectural style , which uses HTTP + JSON.
  • RPC is remote procedure call, client calls server methods like a local method/procedure calls.

Comparison json vs protocol buffer:

topic json protol buffer
Memory foot print JSONS have larger footprint, can turn into a bottle
neck in network transfers
Protocol buffers being binary, it has less foot print
Compute intensive JSONS are more compute intensive due to following:
1. Schema less nature.
2. Human readable, so serialisation and de-serialisation has over head
Being binary and static schema it needs less compute.

why grpc?

  • Efficient messaging protocol.
  • In rest, we need to develop client interface in all possible languages.
  • In grpc, we define services and message formats in protocol buffer.
  • Protocol buffers are language agnostic.
  • Compilers can generate the basic client and server boiler code(API call internals and all). we just need to fill, according to the logic.
  • Reduces the effort of client interfaces.
  • Unlike rest, it supports:
    • server streaming.
    • client streaming.
    • bidirectional streaming.

When grpc is best to use?

  • Micro services.
  • APIs.

Few words on protocol buffer:

  • Protocol buffer is a message format and can be used with rest as well.
  • grpc uses protocol buffer explicitly.
⚠️ **GitHub.com Fallback** ⚠️