Sobes.tech
Junior — Middle

What are the types of calls in gRPC and how do they differ?

sobes.tech AI

Answer from AI

gRPC has four main types of calls, distinguished by the way messages are exchanged between the client and server:

  1. Unary RPC — the client sends a single request, and the server returns a single response.

  2. Server streaming RPC — the client sends a single request, and the server returns a stream of responses.

  3. Client streaming RPC — the client sends a stream of requests, and the server returns a single response.

  4. Bidirectional streaming RPC — both the client and server exchange streams of messages simultaneously.

Each type is suitable for different scenarios: unary for simple requests, streaming for transmitting large volumes of data or long sessions.