Home/Labs/Protocol Selection Matrix
All 280 Labs
INTERACTIVE LAB🔀

gRPC vs REST vs GraphQL Lab (Interactive)

Load each network boundary with records and requests-per-second to compute payload, CPU, and queueing per protocol. Pick mobile-edge, public-partner, or internal-mesh traffic, sweep payload size and offered load, and watch Protobuf binary encoding and HTTP/2 pull away — or saturate.

gRPC vs REST vs GraphQL Matrix

Load each network boundary with real payload, serialization, and queueing math to find the fitting protocol.

link: 7,500 KB/s
ProtocolPayloadSer. CPUTransferQueue @ 12,000 rpsEst. latencyEdge traits
REST (JSON/HTTP1.1) 840 KB18 ms112 msSATURATED∞browser ✓ · CDN ✓ · SSE only
GraphQL (JSON) 420 KB22 ms56 msSATURATED∞browser ✓ · CDN ✗ · WebSocket subs
gRPC (Protobuf/HTTP2) FASTEST HERE180 KB2.1 ms24 ms+0 ms26.1 msbrowser ✗ (gRPC-Web) · CDN ✗ · bi-directional

Service-to-service in VPC: Compile-time .proto contracts, HTTP/2 multiplexing over one TCP connection, and 7-10x CPU headroom dominate here. Architectural recommendation for this boundary: gRPC.

Numbers computed live: Protobuf omits field names (integer tags + varints) so payloads shrink ~70-80% versus JSON; queueing term explodes as offered load passes each server's per-protocol request capacity.

How It Works Under the Hood

Production systems do not pick one protocol; they pick per boundary. gRPC ships binary Protocol Buffers over multiplexed HTTP/2: field names never hit the wire, so payloads shrink 70-80% and deserialization is memory unpacking rather than string scanning, yielding roughly 7-10x the throughput of JSON. REST trades raw speed for universal browsers, curl, Postman, SDK generators, and CDN-friendly GET caching. GraphQL wins frontends by letting clients fetch exact graphs in one round-trip. Queueing math makes the choice concrete: each protocol has a request capacity, and latency explodes as offered load approaches it.

Core Architectural Principles

  • Protobuf integer tags plus varints make 1,000-record payloads ~180KB versus REST’s ~840KB.
  • HTTP/2 multiplexes thousands of streams over one TCP connection, removing handshake starvation.
  • The 3-tier standard: GraphQL for first-party clients, REST for partners, gRPC inside the VPC.
Interview Round Script

Never answer with one protocol. Present the hybrid: gRPC service-to-service for its compile-time .proto contracts and CPU headroom, REST at the public edge for tooling and caching, GraphQL for mobile screens. Justify each with numbers — serialization cost, payload size, browser reachability — and note gRPC-Web proxies as the browser caveat.

Key Trade-Offs

Binary speed and strict typing on gRPC versus unmatched cacheability and debuggability on plain REST JSON.

Related Curriculum Chapter

gRPC vs REST vs GraphQL: The Ultimate Protocol Trade-Off Matrix

Read Full Chapter Blueprint

Explore More Interactive Labs

View All 280 Labs