The usual comparison of gRPC, REST and GraphQL is about contracts, tooling and taste. This one is about cost: what one call puts on the wire, how long it takes on a fast and a slow network, how many calls a server core can answer, and what changes when the data is nested and a client needs only part of it.
All three APIs run in one Go process, over the same TLS 1.3 settings, and call the same functions over the same in-memory store. The only thing that differs between them is the API layer: its encoding, its HTTP framing and, for GraphQL, its query execution. Every response was decoded, reduced to the same canonical form and hashed, and the hash compared with one computed from the store: 38,562,745 calls and 1,120,000 streamed records, 0 mismatches; the same call also produced the same hash on every API.
Setup
Details
Server
One Go 1.26.10 process on 2 cores (GOMAXPROCS=2) · gRPC: grpc-go 1.85.0, protobuf-go 1.36.12, its own HTTP/2 transport · REST/JSON: net/http + encoding/json, HTTP/2 and HTTP/1.1 on one port by ALPN · GraphQL: gqlgen 0.17.98 on the same net/http server, POST with a JSON body, parsed-query cache on · no compression anywhere
Data
1,000 users (id, name, email, a 160-character bio, date, 3 tags, follower count, flag), 10 posts per user, 5 comments per post with their author · small: one user · medium: a page of 100 users · nested: one user’s page, the user’s name, every post’s title and every comment’s text and author name
Nested, per API
gRPC: one RPC returning the whole graph, or (feed fields only) the same RPC filling only the page’s fields · GraphQL: one query selecting exactly the page’s fields · REST?expand=: one request returning the whole graph · REST N+1: GET /users/{id}, GET /users/{id}/posts, then GET /posts/{id}/comments for each of the 10 posts, either one after another or in two parallel waves
Clients
Go 1.26.10, same versions; HTTP/2 through golang.org/x/net/http2 on a connection the client opened itself, so “one connection” is exactly one · gRPC, REST and GraphQL over HTTP/2, REST also over HTTP/1.1
TLS
1.3 everywhere, ECDSA P-256 certificate, X25519MLKEM768 key exchange (Go’s default); connections are opened and warmed before anything is measured
Network
One network namespace, IPv4 loopback at a 1,500-byte MTU with segmentation offloads off · links emulated with tc netem: LAN (nothing added), 50 ms round trip, 200 ms round trip with 1 % random loss in each direction
CPU
AMD Ryzen AI Max+ 395, cores 0–7 reserved for the benchmark · server on cores 2–3, clients on cores 4–7
Method
Every cell is a fresh client process, run 10 times · value: median of the 10 runs (mean of the two middle ones), min–max in the tables · latency p99: all calls of all runs pooled · bytes from the interface counters (every IP packet, both directions) before and after · server CPU from the kernel’s per-thread run time
The scoreboard
Eight headline measures from the sections below, each API's median as a multiple of the best median for that measure (1×; log scale, a longer bar is worse), labelled with the measured value. Median of 10 process runs; grey line: lowest to highest run. REST is REST/JSON over HTTP/2, and for the nested page one ?expand= request; the N+1 variants are in the latency section. Throughput and CPU: 16 callers on one connection, LAN.Eight headline measures from the sections below, each API's median as a multiple of the best median for that measure (1×; log scale, a longer bar is worse), labelled with the measured value. Median of 10 process runs; grey line: lowest to highest run. REST is REST/JSON over HTTP/2, and for the nested page one ?expand= request; the N+1 variants are in the latency section. Throughput and CPU: 16 callers on one connection, LAN.
Measure
gRPC
REST
GraphQL
gRPC vs REST
GraphQL vs REST
Bytes per call, one user
699 B 677–726 B
667 B 667 B
929 B 929 B
0.95×
0.72×
Bytes per call, 100 users
27,215 B 27,190–27,300 B
36,317 B 36,278–36,327 B
36,600 B 36,569–36,607 B
1.3×
0.99×
Bytes per call, nested page
12,993 B 12,905–13,015 B
17,241 B 17,227–17,256 B
9,230 B 9,223–9,242 B
1.3×
1.9×
Latency, one user, LAN
25 µs 24–27 µs
34 µs 32–38 µs
49 µs 46–52 µs
1.4×
0.70×
Nested page, 50 ms link
50.6 ms 50.3–50.7 ms
50.9 ms 50.5–51.1 ms
51.3 ms 50.8–51.6 ms
same
0.99×
Calls/s, one user, 16 callers
132,075/s 130,076/s–133,773/s
63,165/s 61,647/s–65,268/s
40,777/s 39,989/s–41,137/s
2.1×
0.65×
Server CPU per 1,000 small calls
9 ms 9 ms
18 ms 17–19 ms
32 ms 32–33 ms
1.9×
0.56×
Server CPU per 1,000 nested pages
32 ms 31–35 ms
59 ms 58–67 ms
400 ms 397–427 ms
1.9×
0.15×
Median of 10 process runs, lowest to highest run beneath; bold: best in every run; the vs columns: above 1× better than REST, below 1× worse, same: rounds to 1×.
Counting a measure only where every run agrees, against REST: gRPC is better on 6 (up to 2.1× on calls/s, one user, 16 callers), worse on 1 (down to 0.95× on bytes per call, one user) and ties on 1; GraphQL is better on 1 (up to 1.9× on bytes per call, nested page), worse on 7 (down to 0.15× on server CPU per 1,000 nested pages). The sections below take each measure in turn, with REST over HTTP/1.1, the N+1 variants, the slow links and the runs behind every median.
Each API's median against REST's on the same measure, log scale; above 1× it is better than REST (fewer bytes, faster, more calls per second or less CPU). Filled dot: gRPC; hollow: GraphQL. Median of 10 process runs.Each API's median against REST's on the same measure, log scale; above 1× it is better than REST (fewer bytes, faster, more calls per second or less CPU). Filled dot: gRPC; hollow: GraphQL. Median of 10 process runs.
Bytes on the wire per call
On an open connection, what does one call cost on the network, request and response together?
Median of 10 process runs, each making 200 calls (100 for the nested page) on one open connection and reading the network interface counters before and after. After each bar: the response body alone (protobuf or JSON) and, where it is not one, the number of HTTP requests. Each payload has its own scale.Median of 10 process runs, each making 200 calls (100 for the nested page) on one open connection and reading the network interface counters before and after. After each bar: the response body alone (protobuf or JSON) and, where it is not one, the number of HTTP requests. Each payload has its own scale.
For one small record, the API makes little difference: 699 B for gRPC, 667 B for REST over HTTP/2, 929 B for GraphQL. The response bodies differ more (251 B of protobuf against 336 B of JSON), but the request and some 400 bytes of TCP, IP, TLS and HTTP framing are much the same for everyone. GraphQL pays most because its request carries the query text, 262 B more than a REST GET.
At 100 records the encoding takes over. Protobuf sends numbers as variable-length integers and field names as one-byte tags, so the same 100 users are 25,424 B against 33,739 B of JSON, and the call 27,215 B against 36,317 B. Most of the user record is text (names, bio, email), which neither format compresses; with numeric data the gap would be wider.
The nested page shows what selecting fields is worth. The page needs 8,048 B of GraphQL response; REST’s ?expand= returns every field of every object, 15,738 B, and the whole call costs 17,241 B against GraphQL’s 9,230 B. The N+1 version (one request for the user, one for the posts, then one per post for its comments) moves about the same body in 12 requests and pays HTTP framing 12 times: 20,379 B in 61 packets. gRPC returning the whole graph sits between (12,993 B); filling only the page’s fields, which a purpose-built RPC would do, it is the smallest of all, 7,433 B. Selection, not the protocol, decides the bytes here; GraphQL just makes it the client’s choice instead of the server’s.
Latency per call
On the LAN a call costs whatever the software costs:
One call at a time on an open connection, LAN, from the call until the response is decoded and checked. Median of 10 process runs × 200 calls. Each payload has its own scale.One call at a time on an open connection, LAN, from the call until the response is decoded and checked. Median of 10 process runs × 200 calls. Each payload has its own scale.
gRPC answers a small record in 25 µs, REST over HTTP/2 in 34 µs, GraphQL in 49 µs. For the page of 100 users the gap widens to 126 µs, 322 µs and 773 µs: JSON encoding and decoding on both ends against protobuf’s, and for GraphQL its executor walking every field of every user. These are fractions of a millisecond; on any real network the round trip is bigger.
On a slow link, the count of round trips decides:
One page at a time on an open connection. Median of 10 process runs × 50 pages (on the 200 ms link 30 pages in two waves and 20 one by one); the tick is the 99th percentile of every page loaded. RTT = round trips at that link's delay. Each link has its own scale.One page at a time on an open connection. Median of 10 process runs × 50 pages (on the 200 ms link 30 pages in two waves and 20 one by one); the tick is the 99th percentile of every page loaded. RTT = round trips at that link's delay. Each link has its own scale.
With 50 ms between client and server, every API that loads the page in one request takes one round trip: 50.6 ms for gRPC, 51.3 ms for GraphQL, 50.9 ms for REST with ?expand=. The N+1 REST client needs the posts before it can ask for their comments: sent in two parallel waves, 102 ms; one request after another, as a naive client does, 607 ms. On the lossy 200 ms link the same page costs 2,607 ms one by one.
Loss shows in the tail for everyone. On the 200 ms link with 1 % loss, the slowest 1 % of small calls took 807 ms over gRPC and 668 ms over REST: a lost TCP segment waits for a retransmission timeout of at least 200 ms plus the round trip. All three ride the same TCP, and none of them helps with that. Response size starts to matter too: when losses keep TCP’s congestion window small, the page of 100 users (27–37 KB per call) needs a second round trip at the median on every API (401 ms for gRPC, 401 ms for REST), while the nested page in one request (9–17 KB) still takes one (201 ms with ?expand=).
All latencies, median and p99:
Median · p99
LAN
50 ms
200 ms 1 % loss
small · gRPC
25 µs 91 µs
50.6 ms 51.0 ms
201 ms 807 ms
small · REST HTTP/2
34 µs 105 µs
50.5 ms 51.2 ms
200 ms 668 ms
small · REST HTTP/1.1
22 µs 115 µs
50.3 ms 51.1 ms
201 ms 604 ms
small · GraphQL
49 µs 149 µs
50.7 ms 51.2 ms
201 ms 855 ms
medium · gRPC
126 µs 279 µs
50.7 ms 51.2 ms
401 ms 1,009 ms
medium · REST HTTP/2
322 µs 886 µs
51.4 ms 51.8 ms
401 ms 1,054 ms
medium · REST HTTP/1.1
294 µs 878 µs
51.3 ms 52.0 ms
401 ms 1,201 ms
medium · GraphQL
773 µs 2.72 ms
52.2 ms 53.2 ms
402 ms 1,060 ms
nested · gRPC
72 µs 185 µs
50.6 ms 51.1 ms
201 ms 852 ms
nested · GraphQL
332 µs 1.32 ms
51.3 ms 52.1 ms
202 ms 807 ms
nested · REST ?expand=
174 µs 492 µs
50.9 ms 51.3 ms
201 ms 1,005 ms
nested · REST N+1 in 2 waves
277 µs 662 µs
102 ms 102 ms
601 ms 1,212 ms
nested · REST N+1 one by one
518 µs 900 µs
607 ms 611 ms
2,607 ms 3,707 ms
Throughput: concurrency and connections
How many calls per second can a client get from a 2-core server? Callers call as fast as they can; either all of them share one connection, or each has its own.
Callers call as fast as they can for 2 s; calls completed and checked per second, median of 10 process runs. Server: one process on 2 cores; clients on 4 other cores. One connection is one TCP + TLS connection carrying every caller (HTTP/1.1 can only carry one request at a time on it); with as many connections as callers, each caller has its own.Callers call as fast as they can for 2 s; calls completed and checked per second, median of 10 process runs. Server: one process on 2 cores; clients on 4 other cores. One connection is one TCP + TLS connection carrying every caller (HTTP/1.1 can only carry one request at a time on it); with as many connections as callers, each caller has its own.
Calls/s
gRPC
REST HTTP/2
GraphQL
REST HTTP/1.1
small · LAN 1 caller
38k 38k–38k
28k 28k–28k
20k 19k–20k
45k 45k–46k
small · LAN 16 callers, 1 connection
132k 130k–134k
63k 62k–65k
41k 40k–41k
49k 49k–49k
small · LAN 16 callers, 16 connections
101k 99k–102k
83k 81k–86k
50k 50k–51k
144k 143k–145k
small · LAN 128 callers, 1 connection
195k 187k–197k
83k 80k–85k
45k 45k–46k
49k 48k–49k
small · LAN 128 callers, 128 connections
110k 104k–112k
93k 84k–98k
51k 49k–52k
164k 158k–168k
medium · LAN 1 caller
7.7k 7.6k–7.8k
3.0k 2.9k–3.0k
1.2k 1.1k–1.2k
3.2k 3.2k–3.3k
medium · LAN 16 callers, 1 connection
26k 25k–26k
10k 10.0k–11k
2.5k 2.5k–2.6k
10k 9.7k–10k
medium · LAN 16 callers, 16 connections
26k 26k–27k
11k 11k–11k
2.6k 2.5k–2.6k
12k 11k–12k
medium · LAN 128 callers, 1 connection
28k 28k–29k
9.6k 9.3k–9.7k
2.6k 2.5k–2.7k
10k 10.0k–10k
medium · LAN 128 callers, 128 connections
24k 23k–24k
11k 11k–11k
2.3k 2.3k–2.3k
12k 12k–12k
small · 50 ms 1 caller
20 20–20
20 20–20
20 20–20
20 20–20
small · 50 ms 16 callers, 1 connection
318 315–319
315 313–317
314 312–316
20 20–20
small · 50 ms 16 callers, 16 connections
318 314–319
318 315–319
318 314–319
318 315–319
small · 50 ms 128 callers, 1 connection
2.5k 2.5k–2.5k
2.5k 2.4k–2.5k
2.5k 2.4k–2.5k
20 20–20
small · 50 ms 128 callers, 128 connections
2.5k 2.5k–2.5k
2.5k 2.5k–2.5k
2.5k 2.5k–2.5k
2.5k 2.5k–2.6k
One caller is bounded by latency, not by the server: 38,048 gRPC calls a second, 27,981 REST over HTTP/2, 19,658 GraphQL.
HTTP/2 multiplexing works. With 16 callers on one connection, gRPC reaches 132,075 a second, REST 63,165, GraphQL 40,777. REST over HTTP/1.1 cannot multiplex: 16 callers on one connection take turns, 49,217 a second.
More connections are not free. For gRPC, 128 connections give 109,591 a second against 194,946 on one: each connection has its own reader, writer and TLS state on the same 2 cores. REST and GraphQL over HTTP/2 gain a little from them (92,536 against 83,311 for REST). HTTP/1.1 is the opposite: it needs one connection per caller and, given them, does well: 163,563 a second, because a request on its own connection is the simplest thing an HTTP server can do.
What limits it. At gRPC’s peak the server was busy on 1.6 of its 2 cores and the clients on 2.3 of their 4; GraphQL kept the server’s 2 cores almost full (1.9). For the page of 100 users (table) the clients’ decoding was the limit for gRPC and REST, 3.7 of 4 client cores busy, so those rows understate the server.
On the 50 ms link every API carries what its concurrency allows, one call per caller per round trip: about 318 a second with 16 callers and 2,494 with 128, for every API, as long as HTTP/1.1 gets its connections (20 a second on one).
Server CPU per 1,000 calls
The same throughput runs, measured from the server’s side: how much CPU it spent per 1,000 calls answered, with 16 callers.
CPU time of every server thread (from the kernel's per-thread run-time counters) during the 2-second throughput window, divided by the calls completed; 16 callers on one connection (HTTP/1.1: 16 connections, it cannot share one). Median of 10 process runs. Each payload has its own scale.CPU time of every server thread (from the kernel's per-thread run-time counters) during the 2-second throughput window, divided by the calls completed; 16 callers on one connection (HTTP/1.1: 16 connections, it cannot share one). Median of 10 process runs. Each payload has its own scale.
For a small record most of the server’s work is HTTP and TLS. gRPC’s own HTTP/2 transport needs 9.4 ms per 1,000 calls, net/http over HTTP/1.1 about the same, 8.7 ms, and net/http over HTTP/2 twice that, 18.1 ms: in Go, REST’s HTTP/2 costs more than its JSON. For 100 users it is encoding: 51 ms for gRPC, 106 ms for REST.
GraphQL is the outlier: 758 ms per 1,000 pages of 100 users, 7.2× REST’s for the same data. gqlgen resolves and writes the response field by field, checking each against the query, where REST hands a struct to encoding/json in one call. For the nested page, GraphQL costs 400 ms per 1,000 against 59 ms for REST’s ?expand= and 234 ms for the 12 N+1 requests. GraphQL moves fewer bytes and saves the client round trips; the server pays for it in CPU.
Serialisation: protobuf vs JSON
The encoding alone, outside any server: the same Go structs encoded and decoded with protobuf and with encoding/json.
Go's testing.Benchmark, about one second per value, in 10 fresh processes on the client cores; median. Each payload is encoded from, and decoded into, the same structs the servers use; every decode is checked against the original first. Size: the encoded bytes. Each payload has its own scale.Go's testing.Benchmark, about one second per value, in 10 fresh processes on the client cores; median. Each payload is encoded from, and decoded into, the same structs the servers use; every decode is checked against the original first. Size: the encoded bytes. Each payload has its own scale.
Encoding 100 users takes 12.4 µs in protobuf and 29.9 µs in JSON, 2.4×. Decoding is where JSON is slow in Go: 185 µs against 28.3 µs, 6.5×, because encoding/json matches field names as text and uses reflection for each field. For one user both are a few microseconds or less, small next to a network round trip, which is why the LAN latencies above differ by tens of microseconds, not milliseconds.
Streaming: gRPC server streaming vs NDJSON
One request, 2,000 user records back, processed as they arrive. gRPC sends a stream of messages on one HTTP/2 stream; the REST endpoint writes newline-delimited JSON (NDJSON), one object per line, over HTTP/2 or HTTP/1.1 chunked encoding. For comparison: the same 2,000 users as one ordinary JSON array.
One request answered with 2,000 user records (about 0.5 MB of protobuf, 0.7 MB of JSON), read and checked record by record. Median of 10 process runs × 5 streams (3 on the slow links). Thin grey bar: until the first record arrives; thick bar: until the last. A plain JSON array can only be decoded once it has fully arrived. Each link has its own scale.One request answered with 2,000 user records (about 0.5 MB of protobuf, 0.7 MB of JSON), read and checked record by record. Median of 10 process runs × 5 streams (3 on the slow links). Thin grey bar: until the first record arrives; thick bar: until the last. A plain JSON array can only be decoded once it has fully arrived. Each link has its own scale.
Both streams deliver the first record about one round trip after the request (50.4 ms for gRPC, 50.7 ms for NDJSON on the 50 ms link); the JSON array arrives in about the same total time but can be used only at the end, 106 ms. On the wire a record costs 280 B over gRPC and 358 B as NDJSON, the same protobuf-against-JSON ratio as above. On the lossy link the total is TCP’s: 0.5–0.7 MB over a 200 ms path with 1 % loss, where each loss cuts TCP’s sending rate, took 1,905 ms for gRPC (runs ranged 1,403 ms–3,806 ms) and 1,803 ms for NDJSON over HTTP/2 (705 ms–6,408 ms); gRPC finished first in 4 of 10 runs, so the order between the two is noise, the spread is the finding. NDJSON needs nothing but HTTP; what gRPC streaming adds is a typed message per record, flow control per stream, and streams in both directions, which NDJSON cannot do.
What this does not show
Real networks.netem drops packets independently at random and keeps the delay fixed. Real links lose in bursts and vary their round trip; the latency tails would be worse for all three.
Proxies and browsers. Browsers cannot speak gRPC’s HTTP/2 trailers directly; gRPC-Web or Connect needs a translating layer, which adds its own cost. CDNs and HTTP caches understand REST’s GET; GraphQL’s POST and gRPC bypass them unless set up specially. None of that is measured here.
Compression. Nothing was compressed. gzip would shrink the JSON bodies far more than protobuf’s (JSON’s field names repeat), and cost CPU on both ends.
Other implementations. One language, one library per API. grpc-go, encoding/json and gqlgen are common choices in Go, but a faster JSON library, a different GraphQL server, or another language would move the CPU numbers, gqlgen’s most of all.
A real database. The store is in memory, so the business logic costs nearly nothing. With a database behind it, N+1 on the server (GraphQL resolving 50 comment authors one by one) becomes expensive unless batched, and the API layer’s share of the cost shrinks.
Client-bound cells. Clients had 4 cores and checked every response; in the page-of-100 throughput cells for gRPC and REST they, not the server, were the bottleneck.
New connections. Every connection was open before measuring; a TLS handshake costs the same for all three and would add one to two round trips to a first call.
What the numbers say
One small record costs about the same bytes on every API (667 B–929 B); at 100 records protobuf saves 25 % of the call.
For nested data, selection decides the bytes: GraphQL’s page is 9,230 B, REST’s whole graph 17,241 B.
On a slow link, round trips decide latency: one request for the page takes 51.3 ms at 50 ms, N+1 one by one 607 ms. A REST API that offers ?expand= gets the same single round trip.
On a 2-core server, gRPC on one connection answered the most calls per second (194,946 small calls with 128 callers); REST over HTTP/1.1 with a connection per caller came closest (163,563) at the same CPU per call. GraphQL used the most CPU, 7.2× REST’s for a page of 100 users.
HTTP/1.1 needs one connection per concurrent caller; given them, it is a fast way to serve REST. HTTP/2 needs only one; for gRPC, a connection per caller cost 44 % of its throughput at 128 callers.
Protobuf decodes 100 users 6.5× faster than Go’s encoding/json; for one record the difference is a few microseconds.
Streaming: gRPC and NDJSON both deliver the first record after a round trip; gRPC’s records are 78 % of NDJSON’s size on the wire.
Reproduce it
The harness is one Go program: the server with all three APIs over one store, and a client that runs one measurement and prints JSON lines. A driver script runs every cell 10 times on each link:
./certs.sh # throwaway CA and ECDSA P-256 certificate for localhostdocker build -t rpcb . # Go 1.26 build, runs the self-test (store, hashes, protobuf mapping)./up.sh 4-7 2-3 # client cores, server coresdocker exec rb-net tc qdisc replace dev lo root netem delay 25ms limit 100000 # the 50 ms linkdocker exec rb-net rb run -test lat -kind restn -payload nested -n 50 -settle 300ms
Each run prints the latency samples, bytes and packets counted, calls verified against the store, and the content hash of the last response.