05

Demo 05 — REST vs gRPC: Two Protocols

Quarkus 3.33.1 / Java 21 ⏱ ~10 min
cd quarkus-demo-05-grpc
chmod +x demo.sh
./demo.sh

One Quarkus app simultaneously serves REST on :8080 and gRPC on :9000. Same service, two protocols, honest comparison including the localhost caveat.

The honest localhost caveat

⚠️ gRPC unary is slower than REST on localhost. Network cost is zero on loopback. gRPC’s advantages only materialise with real pod-to-pod network latency.

What gRPC wins even on localhost:

  • Server streaming: 1 connection vs 1,000 REST requests
  • High concurrency (c=500): HTTP/2 multiplexing vs 500 TCP connections

In production (pod-to-pod): gRPC wins ~3-4× throughput, ~73% p50 latency.

Streaming modes

# Live stream — one push per second (count=0)
grpcurl -plaintext -d '{"host":"localhost","count":0}' \
  localhost:9000 MetricsService/StreamMetrics

# Benchmark — 1000 messages as fast as possible
grpcurl -plaintext -d '{"host":"localhost","count":1000}' \
  localhost:9000 MetricsService/StreamMetrics

Prerequisites

hey, grpcurl, ghz — see Prerequisites guide.

Reference