Skip to main content
  1. References/
  2. Architecture Design Basics/
  3. Pattern Taxonomy/
  4. Encoding & Data Formats/

Protocol Choices

·· 283 words· 2 mins

🔴 P0 — REST vs gRPC vs GraphQL is a standard interview question

Problem #

How should services communicate? The protocol choice affects latency, developer experience, streaming capability, and tooling ecosystem.

Mechanism #

DimensionRESTgRPCGraphQL
TransportHTTP/1.1 or HTTP/2HTTP/2 (required)HTTP (any)
PayloadJSON (typically)Protobuf (binary)JSON
ContractOpenAPI (optional).proto (required)Schema (required)
StreamingNot native (workarounds)Bi-directional nativeSubscriptions (over WS)
Browser supportNativeNeeds proxy (gRPC-Web)Native
CachingHTTP caching built-inNo standard cachingComplex (query-dependent)
Code generationOptionalBuilt-in (protoc)Built-in (codegen tools)
Learning curveLowMediumMedium-High

Key Trade-offs #

REST: Universal but verbose #

  • Strength: Every language, framework, and tool speaks HTTP+JSON. Caching is built into the protocol (ETags, Cache-Control). Debugging with curl/Postman is trivial.
  • Weakness: Over-fetching (get entire resource when you need one field), no streaming, no built-in schema evolution.

gRPC: Fast but opaque #

  • Strength: Binary serialisation (~10× smaller), HTTP/2 multiplexing, bi-directional streaming, strong schema evolution via Protobuf.
  • Weakness: Browser incompatibility, binary payloads hard to debug, requires proto toolchain, no built-in HTTP caching.

GraphQL: Flexible but complex #

  • Strength: Client specifies exactly what it needs (no over-fetching), strong typing, introspection.
  • Weakness: N+1 query problem on the server, complex caching, difficult rate limiting (every query is unique), security surface area (malicious queries).

Instinct #

Instinct framing: “I’d use gRPC for service-to-service communication where we control both ends and need performance or streaming. REST for public APIs where developer experience and HTTP caching matter. GraphQL only for specific client-facing use cases where over-fetching is a real, measured problem — not as a default.”

References #

DDIA 2e Reference #

  • Chapter 4: RPC and message-passing dataflow