SimuVedaSystem Design Lab Open in the lab

Networking and APIs / Intermediate / 6 min / Updated

REST vs GraphQL vs gRPC: requests, payloads and N+1

Load one phone screen three ways. Count requests, round trips and wasted bytes, then watch GraphQL hit the database N+1 times until DataLoader batches it.

Start the simulation → Change the load, break a part, watch what happens. Free, no sign-up.

In short

What is REST vs GraphQL vs gRPC?

REST exposes resources at URLs, GraphQL lets the client ask for exact fields, gRPC calls typed functions in binary.

Why does it matter?

The API style decides round trips, payload size and how easy the API is to cache, evolve and call from browsers.

What is the trade-off?

REST is simple and cacheable but chatty; GraphQL is flexible but risks N+1 queries; gRPC is fast but needs proxies.

How do you explain it in an interview?

"Public API in REST with GET caching, GraphQL BFF for the mobile app with DataLoader, gRPC between services."

Check yourself

What is the N+1 problem in a GraphQL API?

Answer: One resolver runs one database query per item in a list. A list of 20 posts triggers 20 author lookups; DataLoader batches them into one query.

Why can REST GET responses be cached at a CDN more easily than GraphQL?

Answer: Each resource has its own URL and GET semantics, while GraphQL usually POSTs to one URL. Caches key on method and URL; one POST endpoint gives them nothing to key on.

Where does gRPC fit best?

Answer: Service-to-service calls that want typed contracts and small binary messages. Browsers need gRPC-Web and a proxy; inside the data centre gRPC over HTTP/2 shines.

See it happen in the simulation →

restgraphqlgrpcapi designn+1 problemdataloaderprotobufover-fetchingnetworking and apis

More in networking and apis