Binary Protocol Buffers for RPC — 10x faster than JSON REST, ideal for internal microservice communication.
# user.proto
syntax = "proto3";
service UserService {
rpc GetUser (GetUserRequest) returns (User);
rpc ListUsers (ListRequest) returns (stream User);
}
message User { int32 id=1; string name=2; string email=3; }
# Generate stubs
# protoc --python_out=. --grpc_python_out=. user.proto
# When to use gRPC:
# - Internal microservice communication
# - High-throughput low-latency
# - Streaming data
# - Strongly typed contracts