The question “which is best, REST, GraphQL or gRPC?” has no answer, because they were built to relieve different pains. The useful question is who is calling, and from where. Let me lay out what each optimises for, then say where I land.
REST: resources, plain HTTP, cacheable
REST models your system as resources with URLs and uses the HTTP verbs the web already has: GET to read, POST to create, PUT or PATCH to change, DELETE to remove. Responses are usually JSON. Status codes carry the outcome. Because it rides on ordinary HTTP, everything understands it: browsers, curl, Postman, proxies, CDNs, API gateways. GET responses can be cached by standard mechanisms, which matters a great deal for public, read-heavy data.
Its weaknesses come from fixed response shapes. A mobile screen that needs a user, their last three orders and the delivery status may need three calls (under-fetching), or one call returning a hundred fields the screen ignores (over-fetching). Also, “REST” in many companies means “JSON over HTTP with some verbs”; strict adherence to the original constraints is rare, and that is fine so long as the team is consistent.
GraphQL: the client chooses the shape
GraphQL exposes a typed schema and a single endpoint. The client sends a query naming exactly the fields it wants, including nested relations, and gets back precisely that. For a product with several different frontends, such as web, Android, iOS and a partner portal, this ends the long negotiation over “can you add this field to that endpoint”.
The price is moved, not removed. The server now accepts arbitrary queries, so you must defend against expensive ones with depth limits, complexity limits and timeouts. Naive resolvers produce the N+1 query problem, where fetching a list of 50 items triggers 50 extra database calls, so you need batching (DataLoader is the usual pattern). Standard HTTP caching works poorly because most queries are POST requests to one URL. And errors often come back with a 200 status and an errors array, which surprises monitoring tools built around status codes.
gRPC: fast, strict, between your own services
gRPC defines services and messages in Protocol Buffers files, then generates client and server code in many languages. Messages travel in a compact binary format over HTTP/2, which supports multiplexed calls and streaming in either direction. The contract is enforced by generated code, so a Java service and a Go service cannot disagree about a field’s type without a compile-time or build-time signal.
It shines for internal service-to-service calls where latency and payload size count, and for streaming. Its weaknesses: browsers cannot call it directly without a proxy layer (gRPC-Web), binary messages are not readable in a plain network trace or by curl without tooling, and your partners probably prefer something they can try in five minutes. Schema evolution has rules, too: you add fields with new numbers and never reuse old ones.
A side-by-side view
| REST | GraphQL | gRPC | |
|---|---|---|---|
| Best audience | Public and partner APIs, simple apps | Many varied frontends | Internal services |
| Format | JSON, text | JSON, text | Protobuf, binary |
| HTTP caching | Natural | Awkward | Not applicable in the usual way |
| Streaming | Not built in | Subscriptions, separate | Built in |
| Main risk | Over and under-fetching | Query cost, N+1 | Tooling and browser limits |
Where I land
My default is REST for anything outside your company’s walls, and for most things inside it too. It is boring, the tooling is everywhere, and a new joiner can read a response in a browser. I would reach for GraphQL only when I could name the pain it cures: multiple client teams constantly blocked on backend changes, or screens that truly need data from many services at once. Adopting it because it looks modern, for one web app and one backend team, trades simplicity for a layer you must then secure and tune.
I would pick gRPC for the internal hot paths: a pricing service called thousands of times per second by other backend services, or anything that streams. Using it for a public API in India’s partner ecosystem, where integrators are often small teams with limited time, usually creates support work.
Nothing forces a single choice. A common and sensible shape is gRPC between internal services, a backend-for-frontend or gateway exposing REST or GraphQL to apps, and REST with webhooks for partners. The cost of mixing is that you maintain more than one style of contract, so keep each style where its strength is and write down the rule for which goes where.
Finally, do not settle this by benchmark. The difference in serialisation speed rarely decides user-visible performance; round trips, database queries and payload size usually do. Choose by who your consumers are and what your team can operate well at three in the morning.
Leave a Reply