Communication

gRPC

Understanding gRPC for high-performance service communication.

2 min readConcepts · System Design

What is gRPC?

gRPC is a high-performance RPC (Remote Procedure Call) framework developed by Google. It uses Protocol Buffers for serialization and HTTP/2 for transport.


gRPC vs REST

AspectgRPCREST
ProtocolHTTP/2HTTP/1.1 or HTTP/2
SerializationProtocol Buffers (binary)JSON (text)
ContractStrict (.proto files)Loose (OpenAPI optional)
StreamingBuilt-inRequires WebSocket/SSE
Browser supportLimitedNative
PerformanceFasterSlower

Protocol Buffers

Define your service and messages in .proto files:

syntax = "proto3";

service UserService {
  rpc GetUser (GetUserRequest) returns (User);
  rpc ListUsers (ListUsersRequest) returns (stream User);
}

message GetUserRequest {
  int32 id = 1;
}

message User {
  int32 id = 1;
  string name = 2;
  string email = 3;
}

Communication Patterns

Unary RPC

Unary RPCSequence diagram

Server Streaming

Server StreamingSequence diagram

Client Streaming

Client StreamingSequence diagram

Bidirectional Streaming

Bidirectional StreamingSequence diagram

Benefits

BenefitDescription
PerformanceBinary format, HTTP/2 multiplexing
Type safetyGenerated code from proto files
StreamingNative support for all patterns
Code generationAuto-generate client/server code
Language agnosticSupport for many languages

When to Use gRPC

Good for:

  • Microservices communication
  • Low-latency, high-throughput systems
  • Streaming data
  • Polyglot environments

Not ideal for:

  • Browser clients (limited support)
  • Simple CRUD APIs
  • When human-readable format needed

Interview Tips

  • Explain Protocol Buffers and binary serialization
  • Know the four communication patterns
  • Compare performance with REST
  • Discuss when to choose gRPC vs REST
  • Mention HTTP/2 benefits (multiplexing)

Finished reading?

Mark it done to track your progress in Concepts.