Side by side
| Dimension | GraphQL | gRPC |
|---|---|---|
| Primary abstraction | GraphQL: clients select fields from a typed schema | gRPC: clients invoke typed service methods |
| Typical placement | Client-facing API or aggregation layer | Service-to-service API; also native clients |
| Transport and encoding | Commonly HTTP with JSON responses | Commonly HTTP/2 with binary Protocol Buffers |
| Response shape | Caller selects supported fields | Method defines the response message |
| Streaming | Subscriptions through an additional transport | Native server, client, and bidirectional streaming |
| Browser access | Works with standard browser HTTP clients | Usually gRPC-Web or a gateway, with limitations |
| Caching | Field/entity caches; HTTP caching needs care | Application caches; no automatic HTTP cache reuse |
| Operational controls | Query cost limits, resolver batching, field authorization | Deadlines, cancellation, status codes, stream flow control |
| Schema evolution | Add fields, deprecate old ones, track usage | Evolve messages compatibly; preserve field numbers |
The differences that matter
GraphQL is a query language and execution model; gRPC is an RPC framework. A GraphQL query can request a product, its seller, and selected reviews through one API operation. A gRPC service exposes methods such as GetProduct and ListReviews. You can build an aggregation method in gRPC, but arbitrary field selection is not its default model.
GraphQL moves response-shaping flexibility to callers, but the server still pays for execution. A nested query can trigger many downstream calls or database reads. Batch resolver loads, bound pagination, and enforce query depth and cost limits. gRPC makes the method boundary explicit, but a poorly designed method can still create excessive fan-out or return unnecessary data.
gRPC commonly uses generated stubs and binary Protocol Buffers, which can reduce encoding and payload overhead compared with JSON. That does not establish an end-to-end latency winner: database work, downstream fan-out, network distance, and connection reuse may dominate. Compare equivalent operations and measure the actual workload.
gRPC provides native unary and streaming RPCs, including bidirectional streams, with transport flow control and cancellation support. GraphQL subscriptions describe event delivery, but require a transport implementation, commonly WebSockets or server-sent events. Neither option automatically provides durable replay, reconnect recovery, or application-level bounds on queued messages.
GraphQL works naturally with browser HTTP clients and can centralize client-facing composition, but authorization must cover requested objects and fields. Standard browser APIs do not expose native gRPC directly, so browsers generally need gRPC-Web or a gateway; supported streaming modes depend on the implementation. Both approaches require deliberate caching and compatible schema changes.
Choose GraphQL when
- Web and mobile screens need different subsets of the same entities, and avoiding multiple client round trips matters.
- A client-facing aggregation layer must combine data from several independently owned services.
- Product teams frequently add views that can reuse existing schema fields without adding a new endpoint for each view.
- You can invest in resolver batching, query cost controls, field-level authorization, and query-level observability.
Choose gRPC when
- Internal services need explicit, strongly typed contracts and generated clients across supported languages.
- A workflow needs native client streaming or bidirectional streaming between compatible clients and servers.
- High-volume RPC traffic makes serialization overhead worth measuring and optimizing.
- Callers benefit from standard deadlines, cancellation, status handling, and service-mesh integration, with compatible infrastructure.
A worked example
A marketplace can use both at different boundaries
Suppose a marketplace serves 10,000 product-page requests per second. Each page needs product details, seller information, and 10 reviews; mobile needs fewer fields than desktop. A GraphQL edge can expose both views without separate screen-specific endpoints, while calling product, seller, and review services over gRPC. If review authors are loaded individually, one page could trigger 10 extra user-service calls, creating 100,000 calls per second before caching. Batch those user lookups and cap review pagination. For internal calls, set deadlines within the page latency budget and cancel unnecessary work. This design chooses GraphQL for client composition and gRPC for service contracts, rather than expecting either technology to eliminate fan-out.
In the interview
- Start with the API boundary: browser-to-backend, native-client-to-backend, or service-to-service. Explain why that caller needs flexible field selection or explicit methods.
- Sketch one real operation and count downstream calls. For GraphQL, show batching and pagination; for gRPC, explain method granularity and whether aggregation belongs in a separate service.
- Define the latency budget and propagate it downstream. Explain what happens when one dependency times out, including whether the client can use partial results.
- For streaming, discuss slow consumers, bounded buffers, connection loss, and replay cursors. Transport flow control is not a durable delivery guarantee.
- Describe rollout safety and security: additive schema changes, old-client support, authorization, and retry-safe mutations. Expect probes about duplicate side effects and expensive requests.
Common mistakes
- Claiming gRPC is always faster without comparing equivalent payloads, downstream work, and deployment conditions.
- Assuming one GraphQL request means one backend call, or that a typed schema prevents expensive queries.
- Treating native gRPC as directly usable from any browser, or assuming gRPC-Web supports every native streaming mode.
- Treating either choice as a replacement for caching, authorization, idempotency, or durable event delivery.
Where it comes up
Interview questions where choosing between GraphQL and gRPC comes up.
- Design a news feed like FacebookFeed APIs may compose posts, authors, and interaction state through GraphQL while using bounded internal RPCs for retrieval and ranking.
- Design Facebook MarketplaceListing views combine seller, photo, and listing data, making client composition versus internal service contracts a useful design distinction.
- Design a metrics monitoring system like DatadogTyped batch or streaming ingestion makes gRPC worth evaluating separately from the API used to query dashboards.
- Design an ETA and live location sharing serviceLocation streaming exposes browser transport constraints, slow-consumer behavior, and reconnect requirements that neither API choice solves alone.
Questions people ask
Is GraphQL faster than gRPC?
There is no universal winner. gRPC with Protocol Buffers can reduce serialization and wire overhead, while GraphQL can avoid unnecessary fields or client round trips. Compare the same user operation, including all backend calls and cache behavior.
Can GraphQL and gRPC be used together?
Yes. A GraphQL layer can resolve client-selected fields by calling internal gRPC services. Keep batching, deadline propagation, authorization, and error mapping explicit so that the aggregation layer does not become an uncontrolled fan-out bottleneck.
Which is better for microservices, GraphQL or gRPC?
gRPC is often a good fit for explicit service-to-service contracts, especially when generated clients or streaming matter. GraphQL fits an aggregation boundary where consumers need flexible views across services. Choose based on the boundary and workload, not simply because the architecture uses microservices.