gRPC is a high-performance RPC framework by Google that uses Protocol Buffers for serialization and HTTP/2 for transport. It's significantly faster than REST for service-to-service communication in microservices architectures.

How gRPC Works

gRPC defines services and messages in .proto files, then generates strongly-typed client and server code in any language. A Go service can call a Python service as naturally as calling a local function. HTTP/2 enables multiplexing, streaming, and header compression.

gRPC supports four communication patterns: unary (request-response), server streaming, client streaming, and bidirectional streaming. This flexibility makes it ideal for real-time data processing and inter-service communication.

Why Developers Use gRPC

Use gRPC for internal microservice communication where performance matters. Companies like Netflix, Dropbox, and Google use gRPC between services. For external/browser-facing APIs, stick with REST or GraphQL since browsers don't natively support gRPC.

Key Concepts

  • Protocol Buffers — Binary serialization format that's smaller and faster than JSON — defined in .proto files
  • HTTP/2 — Transport protocol that enables multiplexing, streaming, and header compression
  • Code Generation — gRPC auto-generates typed client/server code from .proto files in Go, Python, Java, C++, etc.
  • Streaming — gRPC supports server-side, client-side, and bidirectional streaming — beyond simple request-response

Frequently Asked Questions

When should I use gRPC instead of REST?

Use gRPC for high-throughput internal service communication, streaming data, and polyglot microservices. Use REST for browser-facing APIs, simplicity, and when you need broad client compatibility.

Can browsers use gRPC?

Not directly. Browsers don't support HTTP/2 trailers needed by gRPC. Use gRPC-Web (a proxy layer) or envoy proxy to bridge the gap.