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:
-
Unary RPC — the client sends a single request, and the server returns a single response.
-
Server streaming RPC — the client sends a single request, and the server returns a stream of responses.
-
Client streaming RPC — the client sends a stream of requests, and the server returns a single response.
-
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.