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

- gRPC holds a thread pool and uses one thread per incoming stream.
- Max thread count is limited by
ResourceQuota.
Async
- An RPC call pushes a request item into a completion queue; you fetch and handle it yourself.
- You need to provide your own thread pool for multithreaded RPC processing (grpc-io: GRPC Server Threading). Example: thread_stress_test.cc.
- Ref: grpc async model 的用途
Thread Safety
- Completion queues are thread-safe (grpc-io).
- Suggested: one completion queue per thread,
numcputhreads (C++ Performance Notes).
Life Cycle
Ref: gRPC Core Concepts
Unary RPC
- Client calls the stub method.
- Server waits for the client's request message.
- Server returns the response.
- Client gets the response.
Bidirectional Streaming RPC
- Client calls the stub method.
- Server waits for the client to start streaming messages.
- 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.