gRPC vs REST Tradeoff Quiz

A 4-question reference set comparing gRPC and REST on the dimensions that matter at interview time: latency overhead, call types, schema evolution, and observability. Pick the right tool for the workload.

Question Bundle
Go
4 questions
grpc
rest-api
api-design
quiz

By CodeSnatch

April 8, 2026

·

Updated May 18, 2026

473 views

12

4.3 (12)

gRPC uses HTTP/2 with binary protobuf framing; REST commonly uses HTTP/1.1 with JSON. List the latency-relevant differences and pick the right pick for a request/reply API with strict p99 budgets.

Examples

Example 1:

Input: Service-to-service call with 5KB request, 5KB response, 200 RPS, p99 budget 30ms
Output: gRPC fits well; protobuf encode+decode + HPACK header compression saves 5-15ms vs JSON over HTTP/1.1
Explanation: Binary framing, header compression, and persistent multiplexed streams reduce overhead per call.

Example 2:

Input: Public web API consumed by browsers and curl scripts
Output: REST + JSON wins on debuggability and zero-tooling clients, even at slightly higher latency
Explanation: gRPC-Web exists but adds proxy complexity; REST has near-universal client support out of the box.
package main

import (
	"context"
	"fmt"
	"time"
)

// ClientParameters mirrors google.golang.org/grpc/keepalive.ClientParameters.
// We re-declare it here so the snippet is self-contained.
type ClientParameters struct {
	Time                time.Duration
	Timeout             time.Duration
	PermitWithoutStream bool
}

type ClientConn struct {
	Target    string
	Keepalive ClientParameters
}

func newClient(target string) (*ClientConn, error) {
	return &ClientConn{
		Target: target,
		Keepalive: ClientParameters{
			Time:                30 * time.Second,
			Timeout:             5 * time.Second,
			PermitWithoutStream: true,
		},
	}, nil
}

func call(ctx context.Context, conn *ClientConn) error {
	ctx, cancel := context.WithTimeout(ctx, 30*time.Millisecond)
	defer cancel()
	_ = ctx
	_ = conn
	return nil
}

func main() {
	conn, err := newClient("svc.example.com:443")
	if err != nil {
		fmt.Println("dial error:", err)
		return
	}
	fmt.Printf("client ready: target=%s keepalive=%v\n", conn.Target, conn.Keepalive.Time)
	if err := call(context.Background(), conn); err != nil {
		fmt.Println("call error:", err)
		return
	}
	fmt.Println("call ok")
}