DISTRIBUTED SYSTEMS & ARCHITECTURE · SUBTOPIC
REST vs. GraphQL vs. gRPC
Pick the right API paradigm for public APIs, mobile BFFs, and internal microservices.
BeginnerPart of API Design & Gateways
Subtopics in API Design & Gateways (2)
In plain words
REST is a fixed restaurant menu (Order #3 gives burger + fries). GraphQL lets you customize exactly what’s on your plate in one trip. gRPC is kitchen shorthand yelled quickly between chefs.
Think of it like…
Fixed combo meal (REST), custom salad bar (GraphQL), internal shorthand (gRPC).
Loading interactive diagram
Loading interactive exercise
Theory & how it works
The hidden trap of GraphQL
GraphQL eliminates over-fetching on mobile, but makes HTTP/CDN caching harder (since most queries POST /graphql) and opens you to N+1 resolver explosions or deeply nested malicious queries unless you add DataLoader batching and query-depth limits.
Key points & practical guide
Summary checklist
- REST = simple, HTTP-cacheable, great default for public APIs
- GraphQL = avoids mobile over-fetching; enforce depth/cost limits
- gRPC = binary Protobuf speed for internal microservice traffic
When to use it
- REST for public APIs
- GraphQL for mobile BFFs aggregating many sources
- gRPC for internal service meshes
Watch out for
- Returning unbounded lists in REST/GraphQL without pagination limits
Quick check
Loading quiz