Skip to content

gRPC ​

Google Remote Procedure Call.

  • Built on HTTP/2: one channel = one connection, and a connection multiplexes many streams.
  • Similar idea to DCOM (Distributed COM): binary interface + RPC.
  • Used by e.g. hashicorp/go-plugin.

Thread Model ​

Sync ​

Sync model:每個進來的 stream 由 thread pool 裡的一個 thread 處理,thread 數量受 quota 限制

  • gRPC holds a thread pool and uses one thread per incoming stream.
  • Max thread count is limited by ResourceQuota.

Async ​

Thread Safety ​

Life Cycle ​

Ref: gRPC Core Concepts

Unary RPC ​

  1. Client calls the stub method.
  2. Server waits for the client's request message.
  3. Server returns the response.
  4. Client gets the response.

Bidirectional Streaming RPC ​

  1. Client calls the stub method.
  2. Server waits for the client to start streaming messages.
  3. The two streams are independent: read and write can be in any order. For example:
    • Server waits until the client has sent all its messages.
    • Server and client play ping-pong.

頁面歷史

Just observe 👀