Difficulty: Intermediate
Compare REST, GraphQL and gRPC. How do you decide which to use for a given system?
There is no best style, only fit. Think of three ways to order food. REST is a printed menu with fixed dishes: everyone understands it, and it is easy to serve at scale. GraphQL is a build-your-own bowl: you specify exactly which ingredients you want, so you get no more and no less. gRPC is the kitchen intercom: a fast, strictly typed channel between staff who already know the protocol.
REST uses resources, URLs and HTTP methods, typically JSON. Strengths: ubiquitous tooling, human readable, works in every browser and language, excellent HTTP caching through CDNs and ETags, simple mental model, easy for public third-party consumption. Weaknesses: over-fetching (endpoint returns fields you do not need), under-fetching (several round trips to assemble one screen), and versioning overhead as clients diverge. Best for public APIs, CRUD-heavy domains, and when caching and simplicity matter.
GraphQL exposes a typed schema and a single endpoint where the client sends a query describing exactly the shape it wants. Strengths: no over or under-fetching, one round trip for nested data, strong typing with introspection, and excellent developer experience for frontend teams with varied clients such as web, iOS and Android, each needing different fields. Weaknesses: HTTP caching is harder because everything is a POST to one URL (persisted queries and GET help); N+1 database query traps; risk of expensive or deeply nested queries requiring depth limits and cost analysis; rate limiting by request count is meaningless; file uploads and error handling (200 with an errors array) are less natural; and it demands schema governance. Best for complex, relational data with many client types, a backend-for-frontend layer, or aggregating multiple services (federation).
gRPC uses Protocol Buffers and HTTP/2. Contracts are defined in .proto files with generated client and server stubs in many languages. Strengths: compact binary payloads, low latency, multiplexed streams, first-class streaming (server, client and bidirectional), deadlines and cancellation built in, and strong backward compatibility rules through field numbers. Weaknesses: not human readable, poor native browser support (needs grpc-web and a proxy), harder debugging with curl, and less friendly for third-party developers. Best for internal microservice communication, high-throughput low-latency paths, and streaming use cases such as telemetry or chat.
How to decide: who is the consumer and how varied are their needs? Public developers and partners lean REST. Multiple first-party frontends with evolving data needs lean GraphQL. Internal service to service on a performance-sensitive path leans gRPC. Many companies combine: gRPC between microservices, a GraphQL or BFF layer for apps, and REST for public and webhook integrations. Netflix, for example, uses gRPC internally and GraphQL federation at the edge.
Other factors: team skill and operational maturity, since GraphQL requires investment in query cost controls and monitoring; caching needs; payload size on mobile networks; real-time requirements, where GraphQL subscriptions, gRPC streaming, WebSockets or SSE come into play; and observability, where REST is easiest.
Don't fall for the trap of saying GraphQL replaces REST. It moves complexity from clients to the server, which is a trade you should make deliberately. And gRPC does not replace REST at the public edge because of browser and tooling friction.
A good closing statement: pick REST by default, GraphQL when client data needs are diverse and chatty, and gRPC for internal high-performance calls.
# REST: two calls, extra fields
GET /v1/users/7
GET /v1/users/7/orders?limit=3
# GraphQL: one call, exact fields
POST /graphql
{ user(id: 7) { name orders(first: 3) { id total } } }
# gRPC (proto)
service UserService {
rpc GetUserWithOrders (GetUserRequest) returns (UserWithOrders);
}
REST returns fixed shapes per URL, GraphQL lets the client select fields, and gRPC defines a typed method contract.
REST, GraphQL, gRPC, API style selection