Dev tools
gRPC vs REST: Differences, Speed and When to Use Each
gRPC vs REST compared: HTTP/2 and Protobuf vs JSON, streaming, performance, browser support, tooling and a clear guide to when to use each.
In gRPC vs REST, the short answer is this: REST sends human-readable JSON over plain HTTP and works with every browser, tool and language, so it's the default for public APIs. gRPC sends compact binary Protocol Buffers over HTTP/2 using a strict, generated contract, which makes it faster, typed end to end and able to stream in both directions, so it shines between your own backend services. Many teams use both: REST at the edge, gRPC inside.
So is gRPC better than REST? Only for some jobs. This guide explains what gRPC is and how it differs from REST, shows a gRPC vs REST example of the same API in both styles, looks at gRPC vs REST performance with real byte counts, adds the gRPC vs REST vs GraphQL question, and ends with a checklist for when to use each.
gRPC vs REST at a Glance
| REST | gRPC | |
|---|---|---|
| What it is | An architectural style for APIs built on HTTP | An RPC framework from Google, now a CNCF project |
| API model | Resources (nouns) with HTTP methods: GET, POST, PUT, PATCH, DELETE | Service methods (verbs) called like local functions |
| Contract | Optional, usually an OpenAPI document | Required .proto file that defines services and messages |
| Data format | Usually JSON (text); XML or others possible | Protocol Buffers (binary) by default |
| Transport | HTTP/1.1 or HTTP/2 or HTTP/3 | HTTP/2 |
| Streaming | Request-response; streaming needs SSE, WebSockets or chunked responses | Unary, server streaming, client streaming and bidirectional streaming built in |
| Code generation | Optional (OpenAPI generators) | Built in: protoc generates clients and servers |
| Browser support | Native | Needs gRPC-Web and a proxy, with limited streaming |
| Human readability | Easy to read and debug with curl | Binary; needs tools like grpcurl |
| Caching | Standard HTTP caching works for GET | No built-in HTTP caching |
| Error model | HTTP status codes | gRPC status codes such as NOT_FOUND, DEADLINE_EXCEEDED |
| Best for | Public APIs, web and mobile clients, simple integrations | Internal microservices, low-latency calls, streaming, polyglot backends |
What Is REST?
REST (Representational State Transfer) is an architectural style that Roy Fielding described in his 2000 doctoral dissertation. It isn't a protocol or a library. It's a set of constraints for building networked systems: clients and servers are separate, every request is stateless and carries everything needed to handle it, responses say whether they can be cached, and all resources are reached through a uniform interface.
In practice, a REST API exposes resources at URLs and uses HTTP methods to act on them:
GET /users/42 -> read user 42
POST /users -> create a user
PATCH /users/42 -> update part of user 42
DELETE /users/42 -> delete user 42Responses are usually JSON, and the HTTP status code tells you what happened: 200 OK, 201 Created, 404 Not Found, 429 Too Many Requests. Because REST rides on plain HTTP, every language, browser, proxy, CDN and command-line tool already understands it. You can test an endpoint with curl in seconds.
The weakness of REST is that nothing forces a contract. Two REST APIs can name, nest and paginate things in completely different ways, and the client only learns the shape of the data from documentation. OpenAPI (formerly Swagger) fills that gap for teams that adopt it, but it's optional.
What Is gRPC?
gRPC is an open-source remote procedure call (RPC) framework. Google built it as the next version of Stubby, the internal RPC system it had used for more than a decade, and open-sourced it in 2015. It joined the Cloud Native Computing Foundation in 2017.
With gRPC you don't design URLs. You define a service and its messages in a .proto file:
syntax = "proto3";
service UserService {
rpc GetUser(GetUserRequest) returns (User);
rpc WatchUsers(WatchRequest) returns (stream User);
}
message GetUserRequest {
int32 id = 1;
}
message User {
int32 id = 1;
string name = 2;
bool active = 3;
}The protoc compiler then generates a typed client and a server skeleton in your language. The client calls GetUser like a local function; gRPC handles serialization, the HTTP/2 connection, deadlines, cancellation and errors. The gRPC project lists idiomatic client libraries in 11 languages, including Go, Java, C++, Python, C#, Node.js, Ruby, PHP, Dart, Kotlin and Objective-C.
The gRPC docs define four kinds of methods:
| Method type | Proto syntax | What happens | Example use |
|---|---|---|---|
| Unary | rpc A(Req) returns (Res) | One request, one response | Get a user by ID |
| Server streaming | rpc A(Req) returns (stream Res) | One request, a stream of responses | Live price feed, LLM token stream |
| Client streaming | rpc A(stream Req) returns (Res) | A stream of requests, one response | Uploading sensor readings in chunks |
| Bidirectional streaming | rpc A(stream Req) returns (stream Res) | Both sides stream independently | Chat, real-time collaboration, speech-to-text |
The Key Differences Between gRPC and REST
Contract first vs contract optional
gRPC is contract first: the .proto file is the API, and both sides are generated from it. If a field type changes, the code won't compile until it's updated. REST is contract optional. Teams that write an OpenAPI spec get similar guarantees, but many REST APIs live only in docs and examples, so mistakes show up at runtime.
Binary Protocol Buffers vs JSON text
Protocol Buffers encode each field as a small numeric tag plus a compact value. Field names never go over the wire, because both sides already know them from the .proto file. JSON repeats every field name in every message and writes numbers as text. The result is smaller payloads and faster parsing for gRPC, at the cost of messages you can't read without tools.
HTTP/2 vs any HTTP version
gRPC is built on HTTP/2. That gives it multiplexing (many calls share one connection without blocking each other), header compression and long-lived streams. REST can run on any HTTP version. Modern servers often serve REST over HTTP/2 or HTTP/3 too, so the transport gap is smaller than many comparisons claim; the format and the streaming model are the bigger differences.
Built-in streaming vs add-ons
Streaming is part of gRPC's design. REST is request-response by nature; to stream, you add server-sent events, WebSockets or chunked responses. Those work well (most LLM APIs stream tokens to browsers with server-sent events), but they're separate mechanisms with their own rules. Our comparison of server-sent events vs WebSockets covers those options.
Resources vs methods
REST models the world as resources and a fixed set of verbs. gRPC models it as functions. Actions that don't fit CRUD, like "transfer funds" or "recalculate invoice", feel natural in gRPC and slightly awkward in REST, where teams invent endpoints like POST /invoices/42:recalculate.
Errors, deadlines and cancellation
REST uses HTTP status codes, which every developer knows but which are coarse. gRPC has its own status codes and adds deadlines: the client says how long it will wait, and if time runs out the call fails with DEADLINE_EXCEEDED. Either side can cancel a call. In a chain of services, deadlines stop one slow service from tying up everything upstream.
gRPC vs REST Performance
gRPC is usually faster than REST with JSON, mainly because of smaller payloads, cheaper serialization and connection reuse over HTTP/2. How much faster depends on the workload, and published benchmarks vary widely, so treat any single multiplier with care.
Worked example: the same user, two formats
Take the User message above with id = 12345, name = "Ada" and active = true.
| Format | Bytes on the wire | What's in them |
|---|---|---|
| JSON (minified) | 39 | {"id":12345,"name":"Ada","active":true} including every field name and quote |
| Protocol Buffers | 10 | 08 b9 60 (field 1, varint 12345), 12 03 41 64 61 (field 2, length 3, "Ada"), 18 01 (field 3, true) |
That's about a quarter of the size for one small message. The ratio changes with the data: long text strings shrink much less, because both formats send the text itself, while messages full of numbers and repeated field names shrink much more. Gzip narrows the gap for JSON over the network, but it costs CPU on both sides.
Where the gap matters:
- Many small calls between services. Serialization and connection setup dominate, and gRPC's binary format plus HTTP/2 multiplexing save real CPU and latency.
- Mobile clients on weak networks. Smaller payloads mean fewer bytes and less battery.
- Streaming. Long-lived streams avoid opening a new request for every update.
Where it barely matters:
- Calls dominated by database time or an LLM response. If the handler takes 800 ms, saving 1 ms on parsing changes nothing.
- Large binary files. Both approaches send the bytes; use direct object storage uploads instead.
- Low traffic. At a few requests per second, developer time matters far more than serialization speed.
The honest summary: measure your own hot paths before switching. If your API isn't CPU- or latency-bound on serialization, gRPC's real advantages are the contract, code generation and streaming, not raw speed.
gRPC vs REST Example: The Same API in Both Styles
Here's how the same small feature looks in each style.
REST:
GET /v1/orders/981 HTTP/1.1
Host: api.example.com
Accept: application/jsonThe response is a JSON body with a 200 status, or a 404 if the order doesn't exist. Any client can call it, and a CDN can cache it.
gRPC:
service OrderService {
rpc GetOrder(GetOrderRequest) returns (Order);
rpc TrackOrder(TrackOrderRequest) returns (stream OrderStatus);
}The client calls GetOrder through generated code, gets a typed Order object back and can subscribe to TrackOrder for live updates over one connection. Clients need the .proto file or generated stubs, and you can't paste the call into a browser address bar.
gRPC vs REST vs GraphQL
GraphQL is the third option that comes up in almost every API debate. Facebook built it internally and open-sourced it in 2015; it's now run by the GraphQL Foundation. Instead of many endpoints, a GraphQL API exposes one endpoint and a typed schema, and the client sends a query that names exactly the fields it wants. The server returns that shape and nothing more.
| REST | gRPC | GraphQL | |
|---|---|---|---|
| Shape of the API | Many URLs, one per resource | Service methods from a .proto file | One endpoint, a typed schema |
| Who decides the response shape | Server | Server (message types) | Client, per query |
| Format | Usually JSON | Binary Protobuf | JSON |
| Real-time | SSE or WebSockets | Built-in streaming | Subscriptions, usually over WebSockets |
| Caching | Standard HTTP caching | None built in | Harder; needs client or persisted-query caching |
| Best for | Public APIs, simple CRUD | Internal service calls, streaming | Front ends that combine data from many sources |
GraphQL solves a different problem from gRPC. It shines when a web or mobile front end needs data from many backend objects in one round trip and different screens need different fields; it avoids both over-fetching (getting fields you don't need) and the chain of requests REST sometimes needs. gRPC solves fast, typed communication between services. A common setup uses all three: GraphQL or REST facing clients, gRPC between the services behind them.
Browser Support and gRPC-Web
Browsers can't speak native gRPC, because JavaScript doesn't get the low-level control over HTTP/2 frames and trailers that gRPC needs. The official workaround is gRPC-Web: the browser sends a slightly different format, and a proxy such as Envoy translates it into gRPC for the backend.
gRPC-Web has limits. According to its project README, it supports unary calls and server streaming (server streaming only in its default text mode), and client-side and bidirectional streaming are not supported. If your web app needs two-way streaming, you'll use WebSockets alongside or instead of gRPC.
Other options exist: Buf's Connect protocol serves gRPC, gRPC-Web and a simple JSON-over-HTTP format from the same server, and tools like grpc-gateway or Envoy's transcoding expose a REST/JSON API generated from your .proto file. These let you keep one contract while giving browsers and partners plain HTTP.
Tooling, Debugging and Ecosystem
REST's biggest strength is everything around it. Curl, Postman, browser dev tools, API gateways, CDNs, logging proxies and every monitoring product understand HTTP and JSON out of the box. A new developer can read a request in a log file.
gRPC tools are good but more specialized: grpcurl and grpcui for manual calls, Postman's gRPC support, server reflection to discover services, and Buf for linting and detecting breaking changes in .proto files. Debugging needs the schema, because a binary message is just bytes without it. Load balancers also need care: because gRPC keeps long-lived HTTP/2 connections, a simple connection-level load balancer can pin all traffic to one backend, so you need a balancer that understands HTTP/2 requests or client-side load balancing.
Rate limiting, authentication and versioning exist in both worlds, but REST's patterns are better known. For REST APIs, our guide to API rate limiting shows how 429 responses and retries work.
Versioning and Evolving the API
Both styles can evolve without breaking clients if you follow their rules.
- gRPC: never reuse or renumber a field tag; add new fields with new numbers; mark removed ones as
reserved. Old clients ignore fields they don't know, so additive changes are safe. Breaking changes go into a new package version, likeuser.v2. - REST: add optional fields freely, never change the meaning of an existing one, and put breaking changes behind a new version in the path (
/v2/) or a header. Tolerant clients that ignore unknown fields make this work.
gRPC enforces more of this through tooling (Buf can fail a build on a breaking change); REST relies on discipline and contract tests.
Who Uses gRPC and REST
Both are everywhere, usually side by side. Public APIs from Stripe, GitHub and most SaaS products are REST with JSON, because their customers use every language and tool imaginable. Google Cloud's APIs are defined in Protocol Buffers and offered over both gRPC and REST. Inside infrastructure, gRPC is common: Kubernetes uses it for the container runtime interface, etcd's v3 API is gRPC, and many service meshes and observability tools speak it natively. Webhooks, which push events to customers, remain plain HTTP; our explainer on webhook vs API covers that pattern.
When to Use gRPC vs REST
Use this as a checklist. If most of your answers land in one column, that's your choice.
| Question | Points to REST | Points to gRPC |
|---|---|---|
| Who calls the API? | External developers, browsers, partners | Your own services and apps |
| Do you control both client and server? | No | Yes |
| Do you need streaming in both directions? | No, or only server to client | Yes |
| Is serialization a measured bottleneck? | No | Yes, high volume of small calls |
| Do you need HTTP caching or CDNs? | Yes | No |
| Several backend languages that must agree on types? | Less important | Very helpful |
| Team experience | Everyone knows HTTP and JSON | Team already uses Protobuf |
When to use gRPC:
- Service-to-service calls inside a microservice system, especially across languages.
- Low-latency, high-volume internal traffic where you've measured serialization cost.
- Real-time streaming between backend services or to native mobile apps.
- Teams that want a strict, generated contract and compile-time checks.
When to use REST:
- Public APIs and anything a third party will integrate with.
- Browser-facing APIs, unless you add gRPC-Web or Connect.
- Simple CRUD services where readability and tooling matter more than speed.
- APIs that benefit from HTTP caching and CDNs.
The common hybrid: REST or GraphQL at the edge for browsers and partners, gRPC between internal services, with a gateway translating where they meet. You get REST's reach and gRPC's efficiency without forcing either on everyone.
Common Mistakes
- Switching to gRPC for speed without measuring. If your latency comes from the database or an external API, the switch adds complexity and no speed.
- Exposing raw gRPC to third parties. Partners expect REST and JSON; give them a gateway.
- Reusing Protobuf field numbers. Changing what tag 3 means silently corrupts data for old clients.
- Forgetting deadlines. A gRPC call without a deadline can hang forever; set one on every call.
- Using a connection-level load balancer. Long-lived HTTP/2 connections stick to one backend; use request-aware balancing.
- Calling REST "slow" because of HTTP/1.1. Serve it over HTTP/2 or HTTP/3 and compress responses before blaming the style.
FAQ
Is gRPC better than REST?
It's better for internal, high-volume or streaming calls between services you control, and worse for public, browser-facing APIs where reach and simple tooling matter more. For speed alone it usually wins: binary Protocol Buffers are smaller than JSON and cheaper to parse, and HTTP/2 reuses connections.
Can gRPC replace REST?
Inside your own systems, often. For public and browser-facing APIs, rarely: browsers need gRPC-Web and a proxy, and most external developers expect REST. Most teams run both.
Does gRPC use HTTP?
Yes. gRPC runs on HTTP/2 and uses its streams, headers and trailers. It just doesn't follow REST's resource and verb conventions, and its messages are binary.
Is gRPC better than REST for microservices?
It's a strong fit when services are in different languages, call each other often or need streaming, because the shared .proto contract and generated clients prevent mismatches. For a few simple services, REST is easier and good enough.
Can I use JSON with gRPC?
Protocol Buffers have an official JSON mapping, and gateways like grpc-gateway or Connect can serve JSON from the same service definition. Native gRPC traffic itself normally uses binary Protobuf.