LumenForgee

gRPC or REST? Choosing a contract style per interaction

Teams often argue about gRPC versus REST as if one had to win for the whole organisation. In practice the right answer differs by interaction. A partner-facing API, a high-frequency internal call and a long-running data stream have different needs, and a platform can support more than one style if the contracts are managed the same way.

Contents
  1. Frame the decision per interaction
  2. Comparing the options
  3. Schema evolution is the real difference
  4. Operational considerations
  5. Running both without chaos
  6. Security and authentication
  7. Worked example: one service, three contracts
  8. Common pitfalls
  9. FAQ
  10. Checklist
  11. Primary sources

Key facts

  • gRPC uses HTTP/2 and, by default, Protocol Buffers for compact binary messages and generated client and server code.
  • gRPC supports unary calls and client, server and bidirectional streaming.
  • Browsers cannot speak native gRPC directly; gRPC-Web or a translating proxy is needed.
  • REST-style APIs over HTTP with JSON are universally accessible and are usually described with OpenAPI.

Frame the decision per interaction

Start by listing the interactions, not the services. A single service might expose a public API to partners, answer frequent internal lookups from other services, and stream changes to an analytics consumer. Each interaction has its own audience, frequency, payload shape and tolerance for coupling.

Then ask the same questions for each: Who are the clients, and what can they easily run? How often is the call made, and how sensitive is it to latency and payload size? Does it need streaming? How will the contract evolve, and who must be told when it does? How will operators debug it at three in the morning?

Comparing the options

Trade-offs between REST/JSON and gRPC/Protobuf
CriterionREST + JSON (OpenAPI)gRPC + Protobuf
Client reachAny language, browsers, command-line toolsGenerated clients; browsers need gRPC-Web
Payload size and parsingLarger, text-basedCompact binary, fast to parse
StreamingServer-sent events, WebSockets or pollingBuilt-in client, server and bidirectional streams
Contract and codegenOpenAPI, optional codegenProto files, codegen is the norm
HTTP caching and intermediariesNative HTTP semanticsLimited; mostly POST over HTTP/2
Debuggingcurl and browser toolsNeeds grpcurl or reflection
Evolution rulesConvention and lintingField numbers and well-defined compatibility rules

Neither column wins overall. REST's reach and HTTP-native behaviour suit public and partner APIs. gRPC's efficiency, streaming and strict contracts suit high-volume internal calls between services that the same organisation controls.

Schema evolution is the real difference

Performance differences are often smaller than expected once connection reuse and compression are in place. The more lasting difference is how contracts evolve. Protocol Buffers identify fields by number. Adding a field with a new number is compatible; renaming a field does not change the wire format; reusing a number for a different meaning is a serious bug, which is why removed numbers should be marked reserved.

JSON APIs identify fields by name and rely on conventions: clients ignore unknown fields, servers treat missing optional fields as defaults. Those conventions work, but only if they are written down and checked. OpenAPI diff tools can detect breaking changes; for Protobuf, linters such as Buf check both style and wire compatibility against the previous version.

Whichever style is used, the contract file belongs in version control, reviewed like code, with an automated compatibility gate in CI. That gate prevents more incidents than any choice of serialisation format.

Operational considerations

  • Load balancing — gRPC multiplexes many calls over long-lived HTTP/2 connections, so connection-level load balancing can send all traffic to one backend. Use request-level (L7) balancing through a proxy or client-side balancing.
  • Deadlines — gRPC propagates deadlines natively; for REST, propagate a timeout budget explicitly in headers.
  • Errors — gRPC has a fixed set of status codes; REST APIs should use HTTP status codes with a consistent body such as Problem Details (RFC 9457).
  • Observability — both are well supported by OpenTelemetry instrumentation; make sure method names, not raw paths with IDs, become span names.
  • Gateways — exposing gRPC services as REST externally is possible through transcoding proxies, which lets one internal contract serve both audiences.

Running both without chaos

A mixed estate stays manageable when the platform treats contracts uniformly: one registry where every API and event contract is listed with its owner, the same review and compatibility gates regardless of format, and documentation generated from the contract rather than written by hand.

Avoid choosing per team by taste. Write a short decision record — for example, partner and browser-facing APIs use REST with OpenAPI; high-frequency internal calls between services owned by the same organisation may use gRPC; streaming between services uses gRPC streams or an event log — and revisit it when needs change.

Security and authentication

Both styles run over TLS and support the same authentication building blocks, but the defaults differ. REST APIs exposed to partners usually rely on OAuth 2.0 access tokens in the Authorization header, with scopes checked per endpoint. Internal gRPC calls more often use mutual TLS between workloads, sometimes combined with tokens that carry the end user's identity in call metadata.

Whichever is chosen, authorisation should be expressed per operation, not per service: a client allowed to read prices is not automatically allowed to change them. gRPC's method names and REST's method-plus-path pairs both map cleanly onto policy rules, which a gateway or a policy engine can evaluate consistently across the two styles.

Rate limits and quotas also need a consistent model. Count requests per client and operation in both styles, and make sure streaming calls are limited by duration or messages, not only by the number of calls, or a single long stream can consume a large share of capacity.

Finally, document how each contract is authenticated in the contract itself. OpenAPI security schemes and gRPC service documentation should state which credentials are expected, which scopes or identities each operation requires, and how errors for missing or insufficient credentials look. Integrators then build against an explicit rule instead of discovering it through failed requests.

Worked example: one service, three contracts

A pricing service is used in three ways: partners request quotes over the internet, the checkout service asks for prices for every basket line, and a reporting pipeline needs a feed of price changes.

  • Partner quotes — REST with JSON, described in OpenAPI, versioned in the URL, published in the developer portal. Partners use their own languages and tools.
  • Checkout lookups — gRPC with Protobuf. Thousands of calls per second, both sides owned internally, deadlines propagated from checkout, client-side load balancing.
  • Price changes — events on a log with a registered schema, consumed by reporting at its own pace.

All three contracts live in the same repository, pass through the same CI gate, and appear in the same registry with the pricing team as owner.

Common pitfalls

  • Choosing one style for the whole organisation regardless of audience.
  • Exposing gRPC directly to browsers or partners without a plan for client support.
  • Reusing Protobuf field numbers after removing fields.
  • Connection-level load balancing for gRPC, concentrating load on one backend.
  • No compatibility gate in CI for either format.
  • Span names containing raw IDs, which breaks trace aggregation.

FAQ

Is gRPC always faster?

Usually more efficient per message, but end-to-end latency often depends more on network, database and connection reuse. Measure with your payloads.

Can we use Protobuf with REST?

Yes, Protobuf can be sent over plain HTTP, and JSON can be used with gRPC transcoding. The format and the transport are separate choices.

What about GraphQL?

It suits client-driven queries over a graph of data, often for front ends. The same governance applies: a versioned schema, compatibility checks and an owner.

Checklist

  • Interactions listed with audience, frequency, payload and streaming needs.
  • Decision record stating which style is used where.
  • Contracts in version control with an automated compatibility gate.
  • Removed Protobuf fields marked reserved.
  • Request-level load balancing for gRPC.
  • One registry of contracts with owners for all styles.

Primary sources

  1. gRPC documentation — Introduction and core concepts
  2. gRPC-Web
  3. Protocol Buffers documentation — Language Guide (proto3)
  4. OpenAPI Specification
  5. RFC 9113 — HTTP/2
  6. RFC 9457 — Problem Details for HTTP APIs

Related research