smaple.tr
Backend & APIs

gRPC vs REST for Microservices: When gRPC Is Worth It

Mehmet Kurtipek
July 4, 2026
12 min read
Backend & APIs
gRPC
REST APIs
Microservices
Protocol Buffers

Use gRPC between microservices when the services call each other often, are written in more than one language, need streaming, or need a contract the compiler enforces. Use REST (JSON over HTTP) for anything a browser, a partner or the public calls, and keep using it internally if you run a handful of services with a small team. gRPC's speed advantage is real, but in systems that size it is rarely the bottleneck, and gRPC adds operational work that REST doesn't. Plenty of systems end up with both: REST at the edge, gRPC between the services behind it.

How the two differ

Between services, "REST" in practice means JSON over HTTP: a URL per resource, the standard verbs and status codes, and ideally an OpenAPI document describing it all. gRPC is an RPC framework that Google open-sourced in 2015 as the successor to Stubby, the RPC system it had used internally for more than a decade. You describe services and messages in a .proto file, generate client and server code from it, and calls travel as binary Protocol Buffers (protobuf) messages over HTTP/2. If you run Kubernetes, you already depend on it: the kubelet talks to the container runtime over gRPC.

REST (JSON over HTTP)

gRPC

Contract

Optional (OpenAPI)

Required (.proto), clients are generated

Payload

JSON text, readable as is

Protobuf binary, needs the schema to decode

Transport

HTTP/1.1 or HTTP/2

HTTP/2

Call types

Request and response; push needs SSE or WebSocket

Unary, server streaming, client streaming, bidirectional

Errors

HTTP status codes plus your own error body

A fixed set of 17 status codes

Browsers

Work natively

Need gRPC-Web, Connect or a REST gateway

HTTP caches and CDNs

Work for GET requests

Don't apply (every call is a POST)

Debugging

curl, browser dev tools

grpcurl, Postman, server reflection

Microsoft's comparison of gRPC and HTTP APIs draws the same lines and recommends gRPC for microservices, multi-language systems, point-to-point streaming and bandwidth-constrained networks.

A contract is short. The Order message in this one is what we used for the measurements further down:

syntax = "proto3";

package shop.v1;

service OrderService {
  rpc GetOrder(GetOrderRequest) returns (Order);
  rpc WatchOrder(GetOrderRequest) returns (stream OrderEvent);
}

message GetOrderRequest {
  string order_id = 1;
}

message Order {
  reserved 4;                // was "double total"; never reuse the number
  string id = 1;
  string customer_id = 2;
  repeated LineItem items = 3;
  int64 total_minor = 5;     // 2599 means 25.99
  string currency = 6;       // ISO 4217, e.g. "EUR"
}

message LineItem {
  string sku = 1;
  int32 quantity = 2;
  int64 unit_price_minor = 3;
}

message OrderEvent {
  string order_id = 1;
  string status = 2;         // "PAID", "PACKED", "SHIPPED"
}

On the wire, a field is identified by its number. That is why a deleted field's number is kept as reserved, and why money is stored as an integer in minor units instead of a double, which can't represent most decimal amounts exactly. WatchOrder returns a stream: the server keeps sending OrderEvent messages within one call, which REST can only approximate with polling, SSE or a WebSocket.

Where the speed difference comes from, and how big it is

Part of it is the connection. HTTP/1.1 keeps connections open by default, so a REST client reuses its connections between requests. Its limit is that a connection returns one response at a time, in the order the requests arrived. Pipelining doesn't change that order and is rarely switched on, so clients keep a pool of connections and still queue behind slow responses. HTTP/2 multiplexes many calls over one connection. A REST API served over HTTP/2 gets the same benefit, so this part isn't unique to gRPC.

The other part is encoding, and we measured that ourselves instead of repeating benchmark figures from other blogs. The test encoded the Order above with three line items, once on its own and once as a response holding 100 orders, as compact JSON (snake_case keys, numbers as numbers) and as protobuf. IDs and SKUs were random strings. It ran on Python 3.12 with protobuf 7.36 and its default upb backend, on an Apple M1 Pro laptop, with each step timed by timeit.

JSON

Protobuf

One order

274 bytes

97 bytes

100 orders

27,499 bytes

9,897 bytes

100 orders, gzipped

5,518 bytes

5,145 bytes

Encode 100 orders (message already built)

about 0.22 ms

about 0.015 ms

Build the messages from Python dicts, then encode

about 0.22 ms (the same json.dumps)

about 0.41 ms

Decode 100 orders and read every field

about 0.25 ms

about 0.20 ms

Uncompressed, protobuf came to just over a third of the JSON size. Compression closes most of that gap for lists: gzipped, the JSON response was only 7% larger. How much gzip recovers depends on how repetitive your data is.

The timings need a closer look. Serialising a message that already exists was about fifteen times faster than json.dumps. But a Python service usually holds dicts or ORM objects, and once the test had to build the protobuf messages from the same dicts first, protobuf took almost twice as long as JSON. Decoding and reading every field was about 20% faster with protobuf. Every one of these numbers is a fraction of a millisecond.

So the difference shows up when a service handles thousands of calls a second, when one user request fans out into dozens of internal calls, when payloads are large, or when clients sit on slow mobile networks. An endpoint that spends 20 ms waiting on a database won't feel it. Results also vary a lot by language and library, so test your own payloads against the same handler: ghz for the gRPC side, your usual HTTP load tool for REST.

When gRPC is worth it

  • Internal calls are frequent or chatty, and you've measured that serialisation or connection handling shows up in latency or CPU.
  • Services are written in different languages. One .proto generates typed clients for Go, Java, Python, C#, Node.js and others, so nobody hand-writes a client or keeps one in sync.
  • You need streaming: progress pushed from the server, a client uploading a large file in chunks, or both sides sending at once.
  • Several teams depend on each other's APIs and you want breaking changes caught in CI before anything ships.

When REST is the better choice

  • The caller is a browser, a partner, an outside developer or a webhook consumer. Everyone can send JSON over HTTP; few want to install protobuf tooling to integrate with you.
  • You run a handful of services in one language. An OpenAPI spec with generated clients gives you most of the contract benefit without new infrastructure.
  • Read-heavy endpoints rely on HTTP caching or a CDN.
  • You need to send the same message to many connected clients, as in a chat room. A gRPC stream is one-to-one with no built-in broadcast; WebSockets or SSE fit better (see our post on WebSocket vs SSE).
  • Nobody on the team will own the extra pieces gRPC needs: a browser gateway, gRPC-aware load balancing, new debugging tools.

Our rule of thumb: with fewer than about five services and one language, stay on REST with an OpenAPI spec, and introduce gRPC at the one boundary that clearly needs it.

What you take on with gRPC

Load balancing

This is usually the first surprise. A gRPC client opens one long-lived HTTP/2 connection and sends every call over it. A connection-level (L4) load balancer picks a backend once per connection, so all of that client's calls land on the same pod while new replicas sit idle. The Kubernetes blog has a clear write-up of why a default Kubernetes Service behaves this way with gRPC. The usual fixes:

  • A headless Service, so DNS returns every pod's IP, combined with the client's round_robin load-balancing policy.
  • An HTTP/2-aware proxy or service mesh (Envoy, Linkerd, Istio) that balances each request separately.
  • Setting MAX_CONNECTION_AGE on the server (it defaults to infinite), so clients reconnect from time to time and new pods start getting traffic.

Two smaller limits from the gRPC performance guide: a stream can't be moved to another backend once it has started, and each connection caps the number of concurrent calls, beyond which new calls wait in the client. For very busy paths the guide suggests a pool of channels.

Deadlines and retries

By default gRPC sets no deadline, so a call to a stuck service can wait indefinitely (gRPC deadlines guide). Set one on every call. Java and Go pass the remaining time on to downstream calls automatically; in C++ you have to switch that on. Retries are enabled in gRPC, but there is no default retry policy: apart from automatic (transparent) retries of calls that never reached your server code, nothing is retried until you configure a policy in the service config. The deadline covers all attempts together. We ran this Python client against a test server that failed twice with UNAVAILABLE; the third attempt succeeded inside the 500 ms deadline:

import json
import grpc
import orders_pb2, orders_pb2_grpc  # generated from orders.proto by grpc_tools.protoc

service_config = json.dumps({
    "methodConfig": [{
        "name": [{"service": "shop.v1.OrderService", "method": "GetOrder"}],
        "retryPolicy": {
            "maxAttempts": 3,
            "initialBackoff": "0.1s",
            "maxBackoff": "1s",
            "backoffMultiplier": 2,
            "retryableStatusCodes": ["UNAVAILABLE"],
        },
    }]
})

channel = grpc.insecure_channel(  # local tests; use secure_channel with TLS in production
    "localhost:50051", options=[("grpc.service_config", service_config)]
)
orders = orders_pb2_grpc.OrderServiceStub(channel)

try:
    order = orders.GetOrder(orders_pb2.GetOrderRequest(order_id="ord_1"), timeout=0.5)
except grpc.RpcError as err:
    if err.code() == grpc.StatusCode.DEADLINE_EXCEEDED:
        ...  # degrade or fail fast
    else:
        raise

Even UNAVAILABLE can arrive after the server has done the work, so attach retry policies only to idempotent methods, or give write requests an idempotency key. A retried CreateOrder that had already succeeded creates a second order. That is why the policy above names GetOrder and not the whole service.

Errors

gRPC has 17 status codes, numbered 0 to 16. Most map to habits you have from HTTP: NOT_FOUND, INVALID_ARGUMENT, PERMISSION_DENIED, UNAUTHENTICATED. UNAVAILABLE means a transient failure worth retrying with backoff, and INTERNAL is reserved for serious errors where an invariant is broken. The gRPC libraries never produce NOT_FOUND, INVALID_ARGUMENT and several others on their own; your handlers have to. When our test handler raised a plain Python exception, the caller received UNKNOWN, which gives it nothing to act on. In Python, a handler returns a real code with context.abort(grpc.StatusCode.NOT_FOUND, "order not found").

Debugging

You can't read protobuf in a log line or call an endpoint with curl. Enable server reflection on non-public servers and use grpcurl:

grpcurl -plaintext localhost:50051 list
grpcurl -plaintext -d '{"order_id": "ord_1"}' localhost:50051 shop.v1.OrderService/GetOrder

Postman also sends gRPC requests, using either reflection or an imported .proto.

Browsers

Browsers don't give JavaScript the level of HTTP/2 control a gRPC client needs, so a web front end can't call a gRPC service directly. There are three ways around it. gRPC-Web goes through a translating proxy (Envoy by default) and supports only unary and server-streaming calls. Connect, a CNCF sandbox project, serves gRPC, gRPC-Web and its own simpler HTTP protocol from the same handlers, and browsers can call it without a proxy. Or keep plain REST for the browser and generate it from the .proto with JSON transcoding (grpc-gateway for Go, built into ASP.NET Core since .NET 7, or Envoy's transcoding filter), often behind an API gateway. If you go that way, know that protobuf's JSON mapping writes int64 values as strings and field names in lowerCamelCase. An order total of 18658 arrives as "totalMinor": "18658", and front-end code has to expect that.

Changing the schema

Adding a field is safe: older clients skip fields they don't know. Renaming one is safe on the wire but breaks generated code and the JSON form. Reusing a field number or changing a field's type corrupts data for anyone on the old schema, so reserve numbers you delete, as protobuf's own guidance says. Running buf breaking --against '.git#branch=main' in CI catches all of these before merge.

Other options worth considering

Not every call between services needs an answer right away. On the odds data platform we built and ran for EdgeHunters, each sportsbook's scraper was a Celery worker fed by Redis queues. A queue absorbs bursts and lets a consumer restart without the producer noticing, which synchronous calls of either kind can't offer.

Two more you'll run into. tRPC (now at version 11) gives a TypeScript front end and its TypeScript backend fully typed calls with no schema and no code generation; it suits a single full-stack TypeScript app and doesn't help across languages. GraphQL fits client-facing APIs where many screens need different shapes of the same data. Between backend services it adds a layer without much in return.

The APIs in our client projects

Our portfolio write-ups don't mention gRPC anywhere; the APIs they describe are plain HTTP APIs. On Oplist, a client we build for, the React front end talks to a Node.js/Express API documented with Swagger, and the roster solver runs as a separate Python service. Planard's Angular app, which we built from scratch, sits on a .NET Core Web API, and the data-migration platform we built for Tribute uses Django REST.

If you'd like a second opinion on this decision for your own system, our backend and API page is the place to start.

Frequently asked questions

Does gRPC need Kubernetes or a service mesh?

No. It runs anywhere HTTP/2 runs. On Kubernetes you do need to handle load balancing, with a headless Service and client-side balancing, a proxy, or a mesh.

Does gRPC require TLS?

The protocol doesn't; plaintext channels are fine for local tests. In production, use TLS, or mutual TLS between services, which a service mesh can manage for you.

Should we migrate our REST services to gRPC?

Only where you've measured a problem gRPC solves. Rewriting working internal endpoints for a speed gain no user will notice costs more than it returns. Where one boundary does need it, you can serve gRPC next to the existing REST endpoint and move callers over one at a time.

Related Articles

August 1, 2026

Kong vs Traefik vs AWS API Gateway: How to Choose

Kong, Traefik and AWS API Gateway compared as of October 2026: features, licensing, Kubernetes support and what AWS charges for 100 million requests a month.

Read More: Kong vs Traefik vs AWS API Gateway: How to Choose
March 14, 2026

RPA Implementation: From Process Choice to Bots That Keep Running

Most of an RPA implementation is choosing the process and designing for exceptions. The order we work in, current license prices, and what broke in the n8n and LLM automation we built with an agency.

Read More: RPA Implementation: From Process Choice to Bots That Keep Running
February 22, 2026

Composable Architecture: What It Is and When It's Worth It

Composable architecture builds a system from replaceable business capabilities joined by APIs. How it differs from microservices and MACH, how to adopt it, and when a small team should skip it.

Read More: Composable Architecture: What It Is and When It's Worth It