karawaci.kode

2026-09-11 · 11 min

gRPC vs REST vs GraphQL for Internal Services in 2026: A Practical Guide

A payments service that fans out to a ledger, a fraud check, and a notification service on every transaction will spend more time serializing JSON than doing actual work if you let it. That is the moment protocol choice stops being academic. I hit exactly this on an internal system for a fintech client running out of a ruko near Golden Boulevard in BSD — the API worked, but p99 latency on the checkout path was creeping past 400ms, and half of it was JSON marshaling across six internal hops. So this is a grounded comparison of gRPC vs REST vs GraphQL for internal services, with the numbers and trade-offs that actually decided things.

Let me be clear about scope up front: internal service-to-service traffic, east-west, inside your own network. Not public APIs. Not mobile clients. The calculus for those is different, and I will flag where.

The one-line summary, then the nuance

REST is the default and it is a good default. gRPC earns its place on high-volume, latency-sensitive internal paths. GraphQL is almost never the right answer for pure service-to-service calls — it is an edge/aggregation tool that keeps getting misapplied to internal transport because teams already know it.

Now the nuance, because the one-liner hides the interesting parts.

REST: the boring choice that is usually correct

Most internal calls are low-volume, request-response, and small. A user service asking an auth service “is this token valid” a few hundred times per second does not need protobuf. REST over HTTP/2 with keep-alive is fine, and everyone on the team can curl it at 2am during an incident. That last point is not a joke — debuggability is a real production property.

// A perfectly good internal REST endpoint. Boring is a feature.
app.post("/internal/v1/tokens/verify", async (req, res) => {
  const { token } = req.body;
  const claims = await verify(token);
  if (!claims) {
    return res.status(401).json({ error: "invalid_token" });
  }
  res.json({ userId: claims.sub, scopes: claims.scopes });
});

The cost REST hides: JSON serialization is not free, there is no enforced schema unless you add one (OpenAPI plus a validator), and every service ends up hand-rolling its own client. That last one bites at scale — you get twelve slightly different retry policies and timeout defaults scattered across the fleet.

Where REST breaks down internally: chatty fan-out and large payloads. When the checkout path I mentioned made six internal calls, the combined JSON parse-and-stringify overhead was measurable in the flame graph, sitting right next to the database time.

gRPC: where it actually paid off

gRPC’s real wins internally are three concrete things, in order of how much they mattered to me:

  1. Binary protobuf payloads — dramatically smaller than JSON, especially for numeric and repeated data.
  2. HTTP/2 multiplexing — many concurrent calls share one connection, no head-of-line blocking at the request level.
  3. A generated, typed client — the same .proto produces the server stub and the client in every language, so the contract cannot drift.

Here is the ledger contract from that project, trimmed:

// ledger/v1/ledger.proto
syntax = "proto3";
package ledger.v1;

service Ledger {
  // Unary: record a single entry
  rpc PostEntry(PostEntryRequest) returns (PostEntryResponse);
  // Server streaming: replay a range without loading it all in memory
  rpc StreamEntries(StreamEntriesRequest) returns (stream Entry);
}

message PostEntryRequest {
  string account_id = 1;
  int64 amount_minor = 2;      // amount in sen, never floats for money
  string currency = 3;         // "IDR"
  string idempotency_key = 4;  // dedupe retries at the ledger boundary
}

message Entry {
  string id = 1;
  string account_id = 2;
  int64 amount_minor = 3;
  int64 balance_after_minor = 4;
  google.protobuf.Timestamp posted_at = 5;
}

Two things worth calling out. First, int64 amount_minor — money as integer minor units, never a float, and protobuf makes that explicit at the schema level. Second, StreamEntries uses server streaming, which is a genuine capability REST cannot match cleanly. Replaying a month of ledger entries as a stream meant the consumer never held the full result set in memory. Doing that over REST means pagination gymnastics or chunked-transfer hacks.

The measured result on the checkout path: converting the four highest-volume internal hops from REST to gRPC brought p99 on that path from ~410ms to ~180ms. Roughly half of that was smaller payloads, the rest was connection reuse eliminating repeated TLS and TCP setup. Not magic — just less work per call, multiplied by call volume.

The cost is real too. You need protobuf tooling in CI, a schema registry or at least a shared .proto repo, and load balancers that understand HTTP/2 (naive L4 balancing pins all streams to one backend — a classic gRPC footgun). Plain-text debugging is gone; you live in grpcurl and structured logs.

The 2026 update: Connect changes the trade-off

The old objection to gRPC — “it is painful at the edge, browsers cannot speak it, you need Envoy” — is much weaker now. Connect (connectrpc.com) serves gRPC, gRPC-Web, and a plain JSON/HTTP protocol from the same handler. One .proto, one server, and clients that range from a browser fetch to a native gRPC call.

// Connect handler — same definition serves gRPC AND browser JSON
import { ConnectRouter } from "@connectrpc/connect";
import { Ledger } from "./gen/ledger/v1/ledger_connect";

export default function routes(router: ConnectRouter) {
  router.service(Ledger, {
    async postEntry(req) {
      const entry = await ledger.post({
        accountId: req.accountId,
        amountMinor: req.amountMinor,
        idempotencyKey: req.idempotencyKey,
      });
      return { entryId: entry.id, balanceAfterMinor: entry.balanceAfter };
    },
  });
}

This is what shifts my default. Previously I told teams: REST at the edge, gRPC internally, and eat the translation cost. With Connect, a service can be gRPC-native for internal callers and still hand a browser a working typed client with no proxy. The wall between “internal protocol” and “edge protocol” gets thinner.

GraphQL: right tool, wrong socket

I keep seeing GraphQL proposed for internal service-to-service traffic, and I keep pushing back. GraphQL solves a consumer-side problem: one client, many data sources, wildly varied field-selection needs. That is your frontend or a BFF. It is not two backend services where the query shape is fixed and known at compile time.

When you put GraphQL between internal services, you pay for a query parser and resolver layer at runtime, you invite N+1 problems, and you get a contract that is harder to make strictly version-safe than protobuf. To solve a problem — flexible field selection — that internal callers with a fixed query do not have.

The one legitimate internal-ish use is federation: composing subgraphs from many teams into one graph for external consumers. Apollo Federation and similar do this well. But note what that is — an aggregation layer facing outward. The subgraphs underneath can and often should still talk gRPC or REST to their own dependencies.

// GraphQL at the BFF: this is the RIGHT place for it
query CheckoutSummary($orderId: ID!) {
  order(id: $orderId) {
    total
    items { name priceMinor }
    payment { status method }   # one client, many backend sources, varied fields
  }
}

That resolver, underneath, calls the order service, the payment service, and the catalog service — and those calls can be gRPC. GraphQL shapes the response for the client; it is not the transport between your services.

A decision table I actually use

SituationReach for
Low-volume internal call, small payload, want easy debuggingREST
High-volume east-west, latency-sensitive, large/repeated payloadsgRPC
Streaming a large result set between servicesgRPC server streaming
Polyglot backend, want one enforced contract per servicegRPC (or Connect)
Browser or mobile needs to call the service directlyConnect, or REST
One client aggregating many sources with varied field needsGraphQL (edge/BFF only)
Composing many teams’ graphs for external consumersGraphQL federation (edge)

What I would tell a team starting today

Default to REST. It is debuggable, universally understood, and correct for the majority of internal calls that are neither hot nor large. Add OpenAPI plus a request validator so the contract is not vibes.

Identify your hot paths with an actual flame graph, not intuition. The checkout path was obvious in the profiler and invisible in code review. Convert those specific hops to gRPC — or Connect if a browser is anywhere in the picture — and put buf breaking in CI so the protobuf contract cannot regress silently.

Keep GraphQL at the edge where it belongs. If your frontend team wants it, give it to them as a BFF over your existing services. Do not let it become the transport layer between backends.

The trap is picking one protocol for everything because uniformity feels clean. It is not clean when a token-verification call carries the weight of a query engine, or when a batch ledger replay is paginated over REST because “we standardized on REST.” Match the protocol to the shape of the traffic. That is the whole discipline.

Ditulis oleh Reza Pradipta