gRPC (Google Remote Procedure Call)

Definition:

gRPC is a high-performance, open-source framework developed by Google that lets services communicate with each other using Remote Procedure Calls (RPC) — just like calling a local function, but across a network.

Core Idea:

“Call a method on a remote server as if it were a local function.”

Key features

FeatureDescription
ProtocolUses HTTP/2 (faster, multiplexed, binary)
SerializationUses Protocol Buffers (protobuf) — compact & fast
Bi-directional StreamingSupports client → server, server → client, and 2-way streaming
Strong TypingStrict types defined in .proto files
Code GenerationAuto-generates client/server code in multiple languages from .proto
EfficientMuch faster than JSON/REST over HTTP/1.1

How It Works:

  • Define service & messages in a .proto file
  • Compile it → generates client & server code
  • Services call each other using typed methods over HTTP/2

gRPC vs REST API:

FeaturegRPCREST
ProtocolHTTP/2HTTP/1.1 (mostly)
Data FormatProtobuf (binary, compact)JSON (text, verbose)
SpeedFasterSlower
StreamingBuilt-in bi-directionalLimited
Browser SupportPoor (requires extra tools)Native
Human-readableNoYes

When to Use gRPC:

Microservices communication ✅ Low-latency, high-throughput systems ✅ Internal services (where browser support isn’t needed) ❌ Avoid for public APIs (due to poor browser support)

Used by:

  • Google
  • Netflix
  • Dropbox
  • Square