In senior, staff, and principal engineering interviews, API communication design serves as a litmus test for distributed systems competence. Candidates who reflexively declare "we will just use REST" or "GraphQL solves all client problems" signal surface-level familiarity rather than architectural depth. Interviewers probe communication protocols to evaluate whether an engineer understands network transports, serialization overhead, connection lifecycle management, caching topologies, and blast radiuses.
Evaluating rest vs grpc vs graphql system design trade offs requires balancing transport mechanics (HTTP/1.1 vs HTTP/2 vs HTTP/3), payload encoding efficiency (JSON vs Protocol Buffers vs AST parsing), client developer experience, and operational complexity.

This guide examines each paradigm from first principles, establishes an architectural decision rubric, examines production topologies, and details live interview defense strategies.
Transport and Serialization Fundamentals
API protocols operate atop transport layers and encoding formats that dictate latency, throughput, and CPU overhead under load.
Transport Protocols: HTTP/1.1, HTTP/2, and HTTP/3
Transport selection determines socket management and concurrency limits:
- HTTP/1.1: A text-based protocol using sequential request-response cycles. Because each connection handles only one in-flight exchange, browsers open up to 6 parallel TCP connections per origin. It experiences application-layer Head-of-Line (HoL) blocking: a slow response stalls subsequent requests queued on that socket.
- HTTP/2: Introduces binary framing and single-connection multiplexing. Multiple bidirectional streams interleave over a single TCP socket concurrently, eliminating application-layer HoL blocking and reducing connection handshake overhead. However, TCP packet loss still triggers transport-layer HoL blocking across all active multiplexed streams.
- HTTP/3 (QUIC): Replaces TCP with UDP-based encrypted multiplexing. Packet drops impact only the affected stream, delivering seamless connection migration and 0-RTT handshakes when mobile clients switch between networks.
Serialization: Textual JSON vs Binary Protobuf
Payload serialization directly impacts network I/O and server CPU utilization:
- JSON: Ubiquitous, human-readable, and schema-flexible. However, repeated string keys (such as
"customer_id") inflate payloads. Parsing ASCII/UTF-8 strings into in-memory structures requires continuous scanning and numeric conversions. - Protocol Buffers (Protobuf): A compact binary serialization format powering gRPC. Field names are substituted with integer field tags (varints), omitting redundant string keys over the wire. Protobuf delivers 5x to 10x faster serialization and 60% to 80% smaller payloads than raw JSON.
// UserProfile.proto - Strongly typed contract with zero field string overhead
syntax = "proto3";
package account.v1;
message UserProfile {
uint64 user_id = 1;
string display_name = 2;
string email = 3;
repeated string role_tags = 4;
}
- GraphQL Document AST: Although responses are delivered as JSON, incoming queries require server-side lexical parsing into an Abstract Syntax Tree (AST), schema validation, and resolver execution, adding runtime compute overhead.
Deep Dive: REST (Representational State Transfer)
REST manipulates resources via standard HTTP verbs (GET, POST, PUT, PATCH, DELETE) and uniform resource identifiers (URIs).
Architectural Strengths of REST
- Native HTTP Ecosystem and Caching: REST integrates directly with standard HTTP caching headers (
Cache-Control,ETag). Edge Content Delivery Networks (CDNs), reverse proxies, and browsers cacheGETresponses without reaching upstream backends. - Universal Interoperability: Every HTTP client (cURL, microcontrollers, web browsers) natively handles REST. It remains the dominant standard for public developer APIs and SaaS integrations.
- Stateless Scalability: Requests encapsulate full authentication context (such as Bearer tokens), allowing instances behind Layer 7 load balancers to scale horizontally without shared session state.
Operational Trade-Offs
- Over-Fetching and Under-Fetching: Fixed endpoint structures force clients to download unused fields or execute sequential network calls (the N+1 roundtrip issue) to assemble aggregate views.
- No Bidirectional Streaming: REST lacks native bidirectional messaging. Workarounds such as Server-Sent Events (SSE) or long-polling require dedicated connections and custom reconnect logic.
// Typical REST Response: GET /api/v1/orders/89214
{
"order_id": 89214,
"customer_id": 10452,
"status": "DELIVERED",
"total_cents": 14950,
"shipping_address": {
"street": "100 Market St",
"city": "San Francisco",
"state": "CA",
"postal_code": "94105"
}
}
When structuring service boundaries, reference our microservices interview questions guide for API gateway patterns.
Deep Dive: gRPC (High-Performance Remote Procedure Calls)
Developed by Google, gRPC is an open-source RPC framework running over HTTP/2 and HTTP/3 transport using Protocol Buffers.
Architectural Strengths of gRPC
- Sub-Millisecond Wire Latency: Binary Protobuf serialization combined with persistent multiplexed HTTP/2 streams minimizes CPU serialization time and connection overhead.
- Strict Schema Contracts & Automated Code Generation: The
.protofile serves as the canonical contract. The Protobuf compiler (protoc) generates type-safe client stubs and server interfaces across Go, Java, Python, C++, and Rust. - Native Streaming Models: gRPC provides first-class support for Unary, Server Streaming, Client Streaming, and Bidirectional Streaming over a persistent TCP socket.
// OrderProcessingService.proto - Unary and Bidirectional Streaming
syntax = "proto3";
package order.v1;
service OrderProcessingService {
rpc GetOrderStatus(OrderStatusRequest) returns (OrderStatusResponse);
rpc StreamOrderTelemetry(stream TelemetryUpdate) returns (stream TelemetryAck);
}
message OrderStatusRequest {
uint64 order_id = 1;
}
message OrderStatusResponse {
uint64 order_id = 1;
string status = 2;
uint32 total_cents = 3;
}
message TelemetryUpdate {
uint64 sensor_id = 1;
double temperature_celsius = 2;
}
message TelemetryAck {
uint64 sensor_id = 1;
bool recorded = 2;
}
Operational Trade-Offs
- Browser Incompatibility: Browsers do not expose low-level primitives to manipulate raw HTTP/2 framing. Web clients require
gRPC-Weband an Envoy translation proxy. - Absence of Edge Caching: Because gRPC uses HTTP
POSTwith binary payloads, commercial CDNs cannot cache responses at edge points of presence. - Wire Inspection Friction: Payloads cannot be inspected via standard browser devtools or packet analyzers without decoding schemas.
When evaluating inter-service coordination, review our breakdown of Kafka vs RabbitMQ system design trade-offs for asynchronous messaging alternatives.
Deep Dive: GraphQL (Declarative Client-Driven Graphs)
Created by Meta, GraphQL is an open-source query language and runtime for declarative data fetching against an explicit type system.
Architectural Strengths of GraphQL
- Precise Field Selection: Clients dictate the exact structure of the payload, eliminating over-fetching over bandwidth-constrained mobile networks.
- Single-Roundtrip Aggregation: A single client query can aggregate data across relational stores, microservices, and third-party APIs via resolver functions.
- Introspective Type System: Schema Definition Language (SDL) enables automated TypeScript generation, query autocompletion, and compile-time query verification.
# Schema Definition (SDL)
type Order {
id: ID!
status: OrderStatus!
totalCents: Int!
customer: Customer!
}
type Customer {
id: ID!
displayName: String!
}
enum OrderStatus {
PENDING
SHIPPED
DELIVERED
}
type Query {
order(id: ID!): Order
}
# Mobile Query: Requests only 2 fields
query GetOrderBrief($orderId: ID!) {
order(id: $orderId) {
status
totalCents
}
}
Operational Trade-Offs
- The N+1 Resolver Bottleneck: Naive parent-child resolvers execute individual queries per child record. Resolving 50 orders and their customers triggers 51 database queries unless batched via
DataLoader. - Query Complexity & DoS Exposure: Deeply nested recursive queries can exhaust database connections and server CPU. Systems must enforce maximum query depth and complexity limits.
- HTTP Caching Overhead: Because queries run over HTTP
POSTto a single/graphqlendpoint, HTTP-level caching requires Persisted Queries overGETor client normalized caches (Apollo, Urql).
To prevent runaway traffic from overwhelming downstream resolvers, review our guide on rate-limiting algorithms for system design.
Architectural Comparison Matrix
In system design interviews, clear side-by-side technical trade-offs illustrate senior-level judgment:
| Dimension | REST | gRPC | GraphQL |
|---|---|---|---|
| Transport | HTTP/1.1, HTTP/2 | HTTP/2, HTTP/3 (strict) | HTTP/1.1, HTTP/2 (POST) |
| Serialization | Textual JSON, XML | Binary Protocol Buffers | Textual JSON response, text AST |
| Granularity | Fixed endpoint responses | Fixed message contracts | Client-specified field selection |
| Performance | Moderate; JSON parsing overhead | Ultra-high; 5x–10x faster serialization | Moderate; AST parsing + JSON |
| Type Safety | Optional (OpenAPI code gen) | Native .proto compilation | Native SDL & schema introspection |
| Streaming | Limited (SSE/WebSockets) | Native bidirectional streaming | Subscriptions (WebSockets/SSE) |
| Edge Caching | Native (Cache-Control, ETag) | None (HTTP POST binary bypasses CDNs) | Requires Persisted Queries |
| Browser Support | Universal native fetch() | Requires gRPC-Web + Envoy proxy | High; robust client libraries |
| DoS Risk | Low; distinct endpoint limits | Low; strict schema validation | High; recursive queries risk DoS |
| Best Fit | Public APIs, SaaS developer integrations | Internal microservice mesh, streaming | Mobile/Web BFF data aggregation |

The Hybrid Production Topology
Enterprise architectures rarely adopt a single protocol across all domains. Instead, teams deploy a hybrid communication topology:
[ Web & Mobile Clients ]
│
├── (GraphQL / REST BFF)
▼
[ API Gateway / BFF Layer ]
│
├── (gRPC over HTTP/2)
▼
┌──────────────────────────────────────────────┐
│ Internal Microservices Mesh │
│ │
│ ┌──────────────┐ gRPC ┌────────────┐ │
│ │ Order Service│ ───────► │Inventory │ │
│ └──────────────┘ └────────────┘ │
│ │ │ │
│ ▼ gRPC ▼ gRPC │
│ ┌──────────────┐ ┌────────────┐ │
│ │Payment Svc │ │Telemetry │ │
│ └──────────────┘ └────────────┘ │
└──────────────────────────────────────────────┘
│
├── (REST / OpenAPI)
▼
[ Third-Party Partners & Public Integrations ]
- Edge Layer (REST): Public third-party ecosystems require zero developer friction. Exposing standardized REST endpoints with OpenAPI specifications ensures broad compatibility without requiring partner teams to compile custom client stubs.
- Client Aggregation (GraphQL or REST BFF): Mobile and web applications route through a Backend-for-Frontend (BFF) layer. GraphQL aggregates data across disparate backend domains into single roundtrips, reducing mobile battery drain and radio wake cycles.
- Internal Mesh (gRPC): Inside the private VPC, machine-to-machine traffic runs over gRPC. Teams benefit from sub-millisecond serialization, bidirectional streaming, and compile-time contract safety.
To structure comprehensive interview solutions, explore our core system design interview guide.
Staff-Level Interview Defense Strategies
Interviewers frequently challenge architectural decisions to assess real-world problem solving.
Question 1: "Why not use gRPC directly from browser clients to maximize speed?"
Model Defense:
"Web browsers lack low-level APIs to control raw HTTP/2 frames directly. Standard JavaScript cannot control window update frames or connection multiplexing. Running gRPC in browsers requires
gRPC-Web, which introduces an intermediate proxy (like Envoy) to translate payloads. This extra hop adds network latency, complicates debugging, and provides negligible real-world benefits over HTTP/2 REST with Brotli compression or a GraphQL BFF."
Question 2: "How do you protect databases against abusive GraphQL queries?"
Model Defense:
"We implement a four-part defense strategy at the gateway:
- Static Depth Limiting: Enforce a strict nesting limit (e.g., maximum depth of 5).
- Query Cost Analysis: Assign scalar fields 1 point and relational connections 10 points multiplied by limits; reject queries exceeding cost thresholds.
- DataLoader Batching: Wrap relational resolvers in DataLoader to consolidate individual queries into batched SQL statements, preventing N+1 queries.
- Persisted Queries: In production, disable dynamic schema introspection and only permit pre-registered query hashes compiled during client builds."
Question 3: "When is REST with HTTP/2 superior to gRPC?"
Model Defense:
"REST over HTTP/2 outperforms gRPC when edge caching and developer accessibility take precedence over raw wire serialization speed. For read-heavy, cacheable datasets (such as product catalogs or public content), edge CDNs serve responses in 10ms without hitting origin servers. Because gRPC sends HTTP
POSTrequests with binary bodies, CDNs cannot cache responses at edge nodes, forcing every request back to origin."
For additional guidance on framing trade-offs and communicating clearly under pressure, consult our articles on architecture decision records in interviews and behavioral interview questions for software engineers.
Frequently Asked Questions
What is the primary performance difference between REST and gRPC?
The performance gap stems from serialization mechanisms and transport requirements. REST serializes textual JSON over HTTP/1.1 or HTTP/2, requiring CPU-intensive string scanning. gRPC serializes binary Protocol Buffers over HTTP/2, mapping fields to integer tags. In microservices, Protobuf serialization is 5 to 10 times faster with 60% to 80% smaller payloads.
Can GraphQL replace gRPC in backend microservice meshes?
GraphQL is suboptimal for internal machine-to-machine microservice communication. Parsing query strings into Abstract Syntax Trees, executing dynamic resolvers, and serializing JSON payloads consumes unnecessary CPU cycles compared to pre-compiled gRPC Protobuf stubs. gRPC remains the industry standard for internal service meshes, while GraphQL shines as a client aggregation layer.
How does HTTP caching work with GraphQL?
Because standard GraphQL requests travel via HTTP POST to a single endpoint, traditional CDNs cannot cache responses automatically. Teams achieve HTTP caching via Automatic Persisted Queries (APQ), where clients submit SHA-256 hashes via HTTP GET requests, enabling CDNs to cache responses keyed by hash and query variables.
Hone Your System Design Delivery with totop.app
Knowing architectural concepts is only half the battle. In live technical rounds, interviewers evaluate your ability to lead whiteboard discussions, defend protocol trade-offs, and solve distributed bottlenecks under time pressure. Review our comprehensive technical interview preparation guide to align your prep strategy.
To test your rapid recall of API protocols and distributed systems fundamentals, try our 60-Second Job Blitz—a free, rapid-fire technical assessment designed to identify knowledge gaps without requiring an account.
When you are ready to simulate realistic staff-level interview loops with real-time feedback on trade-offs and architectural design, explore totop.app pricing and plans to unlock unlimited AI-powered technical mock interviews.
Practice Staff Backend Engineer Questions Live with AI Mock Interviews
Turn any job description across Engineering, DevOps, Data, Marketing, Sales, Finance, or HR into a personalized test and live voice or text AI mock interview on totop.app, or test your speed right now in the 60-Second Staff Backend Engineer Blitz.
Play 60s Staff Backend Engineer Blitz (Free, No Login) | Start 14-Day Free Trial | Browse All Interview Guides