How gRPC works
Call a function on another machine as if it lived in your own process.
gRPC is a high-performance RPC framework: you declare services and messages in a .proto file, and protoc generates matching client and server stubs in many languages. Calling the stub looks like a local function call, but the request travels as compact binary Protobuf over HTTP/2 — multiplexed and fast. It supports unary and streaming calls and shines for internal service-to-service traffic, though it's less browser-friendly than REST.
Define the contract
In a .proto file you declare the service's methods and the message types they exchange, written in Protocol Buffers — a compact, language-neutral, strongly-typed schema. Each field gets a name, a type, and a stable field number that fixes its position on the wire. This single file becomes the contract both the client and server will be built from.
Generate the stubs
You run the protoc compiler over the .proto and it generates matching client and server stubs in whatever languages you choose — Go, Java, Python, C++, and more. Both ends are now built from the exact same contract, so a renamed method or changed type is caught at compile time rather than in production. The generated code handles all the serialization and networking boilerplate for you.
Call it like a local function
Your application code invokes a method on the client stub as if it were an ordinary local function, passing a normal object and getting one back. Underneath, the stub serializes the arguments to binary, sends them across the network, waits for the reply, and deserializes it. The remoteness is hidden — that illusion of a local call is the whole point of RPC.
Travel over HTTP/2
The call is encoded as compact binary Protobuf — far smaller and faster to parse than JSON text — and sent over HTTP/2. HTTP/2 multiplexes many concurrent streams over a single long-lived connection, so calls never queue behind one another and there is no repeated connection setup. The result is low latency and high throughput between services.
Server stub dispatches
On the far side, the server stub decodes the Protobuf bytes back into a typed message and dispatches to your real service implementation, which runs the actual business logic. Because the stub already validated the shape against the schema, your handler receives a well-formed, strongly-typed request. It returns a typed response object the same way.
Response streams back
The result flows back through the server stub, across HTTP/2, and into the client stub, which hands your code a normal return value. Beyond this simple unary (one request, one response) pattern, gRPC also supports server-, client-, and bidirectional streaming over that same connection. This makes it excellent for high-volume internal microservice traffic, though browsers can't speak raw gRPC without a proxy like gRPC-Web.
The problem: making a network call feel like a function call
Inside a single program, calling a function is trivial: you pass arguments, the function runs, and it returns a value, all in nanoseconds within the same block of memory. The moment that function lives on *another machine* — a different microservice, possibly written in a different language, running in a different data center — everything gets harder. You now have to turn your arguments into bytes, send those bytes across a network, have the other side turn them back into structured data, run the work, and reverse the whole process for the reply. Along the way you must agree on a data format, handle connections, deal with failures and retries, and keep both sides in sync as the code evolves. RPC (Remote Procedure Call) is the decades-old idea of hiding all of that machinery so a remote call *looks and feels* like a local one — you call a method, you get a result, and the network is an implementation detail.
The appeal is obvious in a world built from microservices. A modern backend is often dozens or hundreds of small services chattering constantly: an order service calling a payments service calling a fraud service calling an inventory service. That internal traffic is high-volume, latency-sensitive, and — crucially — between machines you *own*, not between your server and an unknown public client. For that setting you want three things above all: speed (small payloads, fast serialization, efficient transport), strong contracts (both sides agree exactly on method names and data shapes, and mismatches are caught early), and good developer ergonomics (calling another service should not mean hand-writing HTTP requests and parsing JSON). Plain REST-over-JSON, wonderful as it is for public APIs, is not optimized for this: JSON is verbose text that is comparatively slow to parse, the contract lives in documentation rather than in code, and every call is a fresh HTTP request-response with no built-in notion of streaming.
gRPC is Google's answer, an open-source, high-performance RPC framework designed for exactly this internal, service-to-service world. It rests on two big technology choices that define everything about it. The first is Protocol Buffers (Protobuf): a compact, strongly-typed, language-neutral way to define your data and service contract in a .proto file, from which a compiler generates client and server code in many languages. The second is HTTP/2 as the transport: a modern, binary, multiplexed protocol that lets many calls share one long-lived connection and enables streaming in both directions. Together these give gRPC its character — tiny binary messages flying over efficient multiplexed connections, with both ends generated from a single shared contract so they can never silently drift apart.
There is a deeper reason gRPC can make choices that would be reckless for a public API: you own both ends. A public REST API must assume its callers are strangers on unknown platforms who will read responses by hand, so text, self-description, and browser-friendliness are non-negotiable. Internal service-to-service traffic is the opposite situation — the same organization writes and deploys both the client and the server, controls the network between them, and can regenerate both sides' code from one schema whenever the contract changes. That control is precisely what *unlocks* the aggressive optimizations gRPC makes: you can use an opaque binary format because no stranger needs to read it, you can demand a compiled schema on both sides because you build both sides, and you can rely on HTTP/2 features because you control the infrastructure end to end. gRPC is, in a real sense, an API style that trades away openness — the thing REST optimizes for — to buy performance and safety in the one setting where openness does not matter. Recognizing that "internal, both ends owned" is gRPC's home turf explains almost every design decision that follows.
It is worth pausing on why RPC as an idea keeps coming back, because gRPC is only the latest in a long line (CORBA, Java RMI, Thrift, and others came before it). The recurring appeal is cognitive: developers already think in terms of functions — call this, get that back — so an abstraction that lets a remote service be invoked with the same mental model removes an entire layer of friction. You do not have to context-switch into "now I am building an HTTP request, choosing a verb, serializing JSON, checking a status code, and parsing a body"; you just call payments.Charge(order). The recurring *danger*, famously articulated as one of the "fallacies of distributed computing," is that this abstraction can lull you into forgetting that the network is *not* like a local call — it is orders of magnitude slower, and it can fail in ways a local function never does (timeouts, partial failures, the server vanishing mid-call). Good RPC frameworks, gRPC included, therefore do not pretend the network is invisible; they make the common case feel local while still forcing you to handle deadlines, retries, and failure statuses explicitly. Holding both halves of that truth — local-feeling ergonomics, network-real failure modes — is the mark of using RPC well.
The trade is that gRPC is optimized for a specific niche and pays for it elsewhere. Its binary Protobuf payloads are not human-readable the way a JSON response is, so you cannot just eyeball traffic in a browser or curl an endpoint and read the result. And because it depends on raw HTTP/2 framing and features browsers do not fully expose to JavaScript, gRPC does not run natively in a web page without a translation proxy. It is a superb choice *inside* your backend and an awkward one at the public, browser-facing edge. The rest of this article follows a gRPC call from contract to response, unpacks Protobuf and HTTP/2, walks through the four call types, and then places gRPC honestly against REST and GraphQL so you know when to reach for it.
Protocol Buffers: the contract and why binary is fast
Everything in gRPC starts with a .proto file — the contract that both sides are built from. In it you define two things: the messages (the data structures you exchange) and the service (the set of methods, or RPCs, you can call). A small example:
message GetUserRequest { int32 id = 1; }message User { int32 id = 1; string name = 2; string email = 3; }service UserService { rpc GetUser(GetUserRequest) returns (User); }
Two details deserve attention. First, every field is strongly typed — int32, string, nested messages, enums, repeated (list) fields — so the shape of the data is fixed and known in advance, not discovered at runtime. Second, every field carries a small integer field number (the = 1, = 2). Those numbers, not the field names, are what actually get written on the wire, and this is the key to two of Protobuf's best properties: compactness and painless versioning. Because the number identifies the field, you can rename name in your code without breaking the wire format, and you can add new fields later (with new numbers) that old clients simply ignore — as long as you never reuse or renumber an existing field, old and new versions interoperate cleanly. This makes evolving a schema across many independently-deployed services far safer than it sounds.
Now the payoff: why binary Protobuf is so much smaller and faster than JSON. A JSON message is text and self-describing — it literally spells out every field name and wraps values in quotes, braces, and commas every single time: {"id":42,"name":"Ada","email":"ada@x.com"}. The receiver must parse that text, match field-name strings, and convert values. Protobuf does none of that. Because both sides already share the schema, the encoder does not need to send field *names* at all — it writes a compact tag built from the field *number* and a type hint, followed by the value packed in an efficient binary encoding (small integers, for instance, use a variable-length format called varint that spends only as many bytes as the number actually needs). The result is a byte stream that is typically several times smaller than the equivalent JSON and dramatically faster to serialize and deserialize, because there are no strings to match and no text to parse — just numbered fields and packed values. Over high-volume internal traffic, that size and speed difference compounds into real reductions in bandwidth, CPU, and latency.
The versioning story is worth expanding, because schema evolution is where naive binary formats usually fall apart and where Protobuf's field-number discipline quietly shines. Distributed systems are never deployed all at once; at any moment you have old and new versions of services running side by side, and they must interoperate. Protobuf handles this through two rules that follow directly from numbering fields. Backward compatibility: a new server can read messages from an old client, because any field the old client omitted simply takes its default value. Forward compatibility: an old server can read messages from a new client, because fields it does not recognize (new numbers) are preserved or skipped rather than causing a parse error. The practical contract is a short list of do-nots: never change a field's number, never change its type, and never reuse a retired number (you mark it reserved instead). Follow those, and you can add fields freely and roll services out independently without a coordinated big-bang deploy. This is a subtle but enormous operational advantage in a microservice fleet, and it is a direct payoff of putting numbers, not names, on the wire.
It also helps to see concretely how varint encoding saves space, since "binary is smaller" can sound like hand-waving. A JSON number like "id":42 costs eight bytes of text just for that field. Protobuf writes a one-byte tag (combining the field number and wire type) and then encodes 42 as a single byte, because varint uses only as many bytes as the magnitude needs — small numbers, which dominate most real data (ids, counts, flags, enum values), cost one byte; larger ones grow gradually. Strings are length-prefixed rather than quoted and escaped, and absent fields cost *nothing* at all rather than appearing as null. Across a message with many small fields the savings compound, and because there are no field-name strings to emit or match, both encoding and decoding are largely a matter of reading numbers and copying bytes — which is why Protobuf is not just smaller but markedly faster to process than parsing and validating JSON text.
The second gift of the .proto file is code generation. You run the Protobuf compiler, protoc (with a gRPC plugin), over the file, and it emits ready-to-use source code in your chosen languages: message classes with typed getters and setters, plus stubs — a client stub with a method for each RPC, and a server-side base class with a method for you to implement. Because both the Go client and the Python server (say) are generated from the *same* .proto, they are guaranteed to agree on method names, argument types, and return types. If someone changes the contract, regenerating the code surfaces the mismatch as a compile error on both sides rather than a runtime surprise in production. This is a profound reliability win over passing untyped JSON around and hoping the two teams read the same doc. The contract is not a wiki page that drifts out of date — it is a file in version control from which the code is mechanically derived, so the code and the contract cannot disagree. This combination — compact typed binary messages plus generated, always-in-sync stubs — is the foundation everything else in gRPC builds on.
The call, end to end: stubs, HTTP/2, and multiplexing
With the contract compiled into stubs, let us trace a single GetUser call from start to finish and see how the illusion of a local function call is maintained.
It begins in your application code, which holds a client stub object generated from the .proto. You build a request message — GetUserRequest{ id: 42 } — and call stub.GetUser(request). To your code this is just a method call that returns a User; the remoteness is completely hidden. Underneath, the stub does the real work. It serializes your request message into compact binary Protobuf, attaches metadata (things like authentication tokens, deadlines, and the fully-qualified method name), and hands the bytes to the transport layer.
That transport is HTTP/2, and choosing it rather than HTTP/1.1 is central to gRPC's performance. Under HTTP/1.1, a connection handles one request-response at a time; to do many calls concurrently you open many connections, and even then responses on a connection must come back in order — a slow response blocks the ones behind it, the classic *head-of-line blocking* problem. HTTP/2 fixes this with multiplexing: a single long-lived TCP connection is divided into many independent streams, and each gRPC call gets its own stream. Dozens of calls can be in flight over that one connection simultaneously, their message frames interleaved on the wire and reassembled on the other side, with no call blocking any other. HTTP/2 is also binary rather than text and supports header compression, both of which suit gRPC's low-overhead goals. And because streams are inherently bidirectional and long-lived, HTTP/2 is what makes gRPC's streaming call types (next section) possible in the first place. Establishing that one connection also amortizes the cost of the TCP and TLS handshake across thousands of subsequent calls, instead of paying it per request.
It is worth making the multiplexing win concrete, because it is the single biggest reason gRPC feels fast under load. Imagine one service that needs to make fifty calls to another to build a response. Under HTTP/1.1, it would either open fifty connections (each with its own TCP and TLS handshake, its own memory, its own congestion-control state) or reuse a few connections and let the calls queue up behind one another, where one slow response stalls everything lined up behind it — head-of-line blocking. Under HTTP/2, all fifty calls become fifty streams on a *single* connection. Their frames are chopped up and interleaved on the wire, so a slow call occupies its own stream without blocking the other forty-nine, and there is exactly one handshake to amortize across all of them. For the dense, high-fan-out call patterns typical of a microservice backend — where handling one user request might touch a dozen downstream services — this difference between "fifty independent, non-blocking streams over one pipe" and "fifty connections or a queue" is the difference between a system that stays responsive under load and one that collapses into connection churn and latency spikes.
HTTP/2 also underpins gRPC's use of trailers — metadata sent *after* the message body — which is how the final status code and any trailing metadata ride along at the end of a response, and it is part of why gRPC needs genuine HTTP/2 rather than HTTP/1.1. Flow control is built in per-stream, so a fast sender cannot overwhelm a slow receiver, which matters enormously once streaming enters the picture. And because the connection is long-lived, gRPC layers useful behaviors on top of it: channels that manage a pool of connections and transparently reconnect, client-side load balancing that spreads streams across several server instances, and keepalive pings that detect a dead peer. None of this is something the application programmer writes; it comes from the framework sitting on the HTTP/2 transport, which is exactly the kind of heavy lifting that makes "just call the stub" a realistic promise rather than a leaky one.
The binary Protobuf message, wrapped in an HTTP/2 stream, travels to the server. There, gRPC's runtime receives the frames, identifies which method was called from the metadata, and routes to the matching server stub. The server stub deserializes the bytes back into a typed GetUserRequest object and calls the one method you actually wrote: your implementation of GetUser. Your handler runs the real business logic — perhaps a database lookup — and returns a typed User object. It receives clean, validated, strongly-typed data, never raw bytes, because the stub already did the decoding and the shape is guaranteed by the schema.
The return trip mirrors the request exactly. The server stub serializes your User result into binary Protobuf, sends it back over the same HTTP/2 stream, and the client stub on the far end deserializes it into a User object and hands it back as the return value of the stub.GetUser(request) call your code made. As far as your application is concerned, you called a function and got a typed result; everything in between — serialization, the network, multiplexing, deserialization — was handled by generated code and the gRPC runtime.
Two cross-cutting features ride along the whole way. Deadlines let the client say "give up if this takes longer than 200ms," and that budget propagates through the call so the server can stop wasting work on a request the client has already abandoned. Status codes give every call a structured outcome — OK, NOT_FOUND, DEADLINE_EXCEEDED, UNAVAILABLE, PERMISSION_DENIED, and so on — a richer, RPC-oriented error vocabulary than HTTP's numeric codes, so the caller can react precisely to failures. This is what "make a network call feel like a function call" actually requires under the hood: a shared contract, fast binary encoding, an efficient multiplexed transport, and structured handling of the failures that only exist because there *is* a network.
Four call types: unary and the three flavors of streaming
Because gRPC runs on HTTP/2 streams, it is not limited to the single request / single response pattern that dominates REST. It defines four call types, and choosing the right one is a real part of designing a gRPC service.
Unary is the familiar case and the one traced above: the client sends one request message and gets back one response message. GetUser(id) -> User. It maps directly onto how we think about ordinary function calls and covers the large majority of RPCs — fetch a record, submit a form, run a command. If you are unsure which type to use, it is almost always unary.
Server-streaming keeps a single request but lets the server return a *stream* of many response messages over time, all on one call. The client asks once; the server sends back message after message until it is done, then closes the stream. This fits any "one question, a long or open-ended answer" shape: subscribing to a feed of updates, downloading a large result set in chunks so the client can start processing before it all arrives, or watching a resource for changes. WatchPrices(symbol) -> stream Price would push a new Price every time the market moves, all within one call rather than forcing the client to poll repeatedly.
Client-streaming is the mirror image: the client sends a stream of many request messages and the server replies once, after the client signals it is finished. This suits uploading or aggregating a large or continuous input into a single result. Streaming the chunks of a large file for the server to assemble, or sending a long series of sensor readings that the server averages into one summary, both fit Upload(stream Chunk) -> UploadSummary. The client feeds data in over time; the single response comes at the end.
Bidirectional streaming combines both: client and server each send a stream of messages independently over the same long-lived connection, in any order, at the same time. Neither side has to wait for the other, and the two streams are decoupled. This is the most powerful and the most complex pattern, suited to genuinely interactive, real-time exchanges: a chat where messages flow both ways, a multiplayer game syncing state continuously, or a live collaboration session. Chat(stream Message) -> stream Message lets each participant send and receive messages continuously through one call.
What makes all four feel natural rather than exotic is that HTTP/2 streams are bidirectional and long-lived by design, so streaming is not bolted on — it falls out of the transport gRPC already uses. The generated stubs expose these as language-appropriate constructs: an iterator or channel you read messages from for a server stream, a writer you push messages into for a client stream, and both for bidirectional. Your code still works with typed message objects; the framework handles the framing and flow control underneath.
Declaring these in the .proto is pleasingly uniform: the difference between the four types is just the stream keyword on the request side, the response side, both, or neither. rpc GetUser(GetUserRequest) returns (User) is unary; rpc WatchPrices(Symbol) returns (stream Price) is server-streaming; rpc Upload(stream Chunk) returns (Summary) is client-streaming; and rpc Chat(stream Message) returns (stream Message) is bidirectional. The compiler then generates the appropriate stub shape for each — a plain return value, an iterator, a writer, or both — so the streaming semantics are baked into the generated code and the type system, not left to convention. This is a direct benefit of the contract-first model: the *kind* of interaction is part of the schema, visible to everyone building against it.
The reason all four fall out so naturally is worth restating, because it ties the whole concept together: an HTTP/2 stream is, at the protocol level, already a bidirectional, long-lived channel over which either side can send a sequence of frames whenever it likes. Unary is just the degenerate case where each side sends exactly one message and then closes. Server-streaming is the client sending one and the server sending many; client-streaming is the reverse; bidirectional is both sides using the channel to its full capability. So gRPC did not have to invent streaming — it inherited it from the transport, and Protobuf messages are simply the units that flow along the stream. This is a clean illustration of a good architectural fit: because the transport (HTTP/2 streams) and the payload format (self-delimiting Protobuf messages) both natively support "a sequence of messages over one connection," rich streaming interactions come almost for free, whereas bolting equivalent behavior onto request-response REST requires awkward workarounds like long-polling, chunked transfer tricks, or a separate WebSocket protocol.
The practical guidance is to reach for streaming only when the interaction genuinely is one — large or unbounded data sets, long-lived subscriptions, or real-time two-way communication. Streaming adds complexity in error handling, backpressure (what happens when one side produces faster than the other consumes), and connection lifecycle management, so it should earn its place. For the everyday "fetch this, do that" calls that make up most service-to-service traffic, plain unary calls are simpler and entirely sufficient. Knowing that the streaming options exist, though, is part of understanding why gRPC is such a strong fit for high-throughput internal systems: patterns that would be awkward to bolt onto request-response REST — live feeds, chunked uploads, interactive sync — are first-class citizens here, sharing the same contract, the same connection, and the same compact binary encoding as the simple calls.
Trade-offs and failure modes: living with the abstraction
gRPC's core promise — a remote call that feels local — is powerful precisely because it hides so much, and the trade-offs all stem from what that hiding cannot make go away: the network is still slow, still fallible, and still binary underneath. A team adopting gRPC signs up to manage a specific set of realities, and understanding them is what separates using gRPC from using it *well*.
The first is a richer, more explicit error and failure model than a local call ever needs. Every gRPC call ends with a status code drawn from a fixed set — OK, NOT_FOUND, INVALID_ARGUMENT, PERMISSION_DENIED, UNAVAILABLE, DEADLINE_EXCEEDED, RESOURCE_EXHAUSTED, and more — a vocabulary designed for RPC rather than for documents, so the caller can react precisely. This matters because remote calls fail in ways local ones do not: the server might be down (UNAVAILABLE), the request might time out, or the network might drop mid-flight. gRPC surfaces these as structured statuses rather than exceptions you might forget to handle, but it is on you to handle them — to decide, for instance, that UNAVAILABLE is worth a retry while INVALID_ARGUMENT never is.
That leads directly to deadlines, cancellation, and retries, which gRPC treats as first-class rather than afterthoughts. A client sets a deadline — "fail if this has not completed in 200ms" — and, crucially, that deadline *propagates* down the call chain: if service A calls B calls C, all under one budget, then when the budget expires every service in the chain can stop wasting work on a request the original caller has already given up on. This propagation is essential to preventing cascading overload, where a slow dependency ties up threads and connections all the way up the stack. Retries interact subtly with the four call types and with idempotency: retrying a unary read is safe, but blindly retrying a call that charges a credit card is not, so gRPC's retry policies must be configured with an understanding of which methods are safe to repeat — the same idempotency concern that governs HTTP verbs, made explicit.
The second reality is operational opacity. Because payloads are binary Protobuf, you cannot debug by reading traffic the way you can with JSON; you need schema-aware tooling like grpcurl to introspect a service or craft a test call. Observability takes deliberate work: distributed tracing, structured logging of status codes and latencies per method, and metrics that distinguish a healthy OK from a creeping rate of DEADLINE_EXCEEDED. None of this is impossible — the ecosystem is mature — but it is not the "open a browser and look" experience REST offers, and teams underestimate the tooling investment at their peril.
The third, and most surprising to newcomers, is that gRPC's greatest performance feature — long-lived, multiplexed HTTP/2 connections — quietly *breaks* the naive way we usually load-balance. A traditional layer-4 (connection-level) load balancer spreads *connections* across backends, but a gRPC client opens *one* connection and sends thousands of calls down it, so that whole stream of work pins to a single backend and the others sit idle. Proper gRPC load balancing therefore has to happen at layer 7, balancing individual *requests* (streams) rather than connections — which is why gRPC is usually deployed with client-side load balancing, a service mesh like Envoy or Linkerd, or a proxy that understands HTTP/2. This is a concrete example of an abstraction leaking: the very thing that makes gRPC fast forces you to rethink a piece of infrastructure you took for granted with HTTP/1.1.
Streaming, powerful as it is, introduces its own failure modes that unary calls never face, and they are worth naming because they surprise teams. The first is backpressure: in a stream, one side can produce messages faster than the other can consume them, and without flow control the fast producer would exhaust memory buffering data the slow consumer has not read. gRPC leans on HTTP/2's built-in per-stream flow control to throttle the producer automatically, but application code still has to be written to respect it — a streaming handler that reads its entire input into memory before processing defeats the point and can fall over on a large stream. The second is partial failure: a stream can break halfway through, after some messages have been delivered and others have not, so both sides need logic to detect the broken stream, decide what was and was not processed, and recover — reconnecting, resuming, or reconciling — rather than assuming a call either fully succeeded or fully failed the way a unary request does. The third is lifecycle management: long-lived streams hold resources open, so servers must guard against clients that open streams and vanish, and against slow-loris-style patterns where many idle streams tie up capacity. None of this makes streaming a bad idea, but it is why the earlier advice to use it only when the interaction genuinely warrants it is more than a style preference — streaming moves you from simple request-response reasoning into the harder world of stateful, long-running connections.
Finally there are the contract-evolution disciplines from earlier, which are a trade-off as much as a gift. The safety of a compiled schema comes with the obligation to follow Protobuf's compatibility rules religiously (never renumber or reuse fields), to regenerate and redistribute stubs when the .proto changes, and to manage those generated artifacts across many repositories and languages — often with a shared schema registry and CI checks that reject breaking changes. This is real process overhead that a loosely-typed JSON API avoids. The honest picture, then, is that gRPC does not eliminate distributed-systems complexity; it *names* it — deadlines, retries, idempotency, status codes, layer-7 balancing, schema governance — and gives you first-class tools to handle each. That explicitness is exactly why it is beloved for serious internal infrastructure and overkill for a simple app, a judgment we can now make precisely by comparing it head-to-head with REST and GraphQL.
gRPC versus REST and GraphQL: strengths, weaknesses, and the browser problem
Having seen how gRPC works, it helps to place it directly against the two API styles from its sibling concept, because they optimize for different worlds.
Against REST, the contrasts are sharp. REST uses human-readable JSON text over HTTP/1.1 (typically), with its contract living in documentation and its responses trivially cacheable by any HTTP intermediary. gRPC uses compact binary Protobuf over multiplexed HTTP/2, with its contract living in a .proto file that generates typed code for both sides. So gRPC wins decisively on performance (smaller payloads, faster parsing, one multiplexed connection instead of many), on strong typing and contracts (mismatches caught at compile time rather than in production), and on streaming (first-class, in four flavors, versus REST's request-response). REST wins on simplicity, ubiquity, human-readability, and caching: you can curl a REST endpoint and read the result, every tool speaks HTTP and JSON, and the whole HTTP caching ecosystem works out of the box — none of which is true for gRPC's opaque binary POSTs to a single logical endpoint. REST's inefficiency (the over- and under-fetching that motivates GraphQL) matters far less between internal services on a fast network than it does over a phone's cellular link.
Against GraphQL, the difference is one of purpose rather than raw speed. GraphQL exists to give *client* applications flexible, exact-shape access to a connected data graph, letting a UI ask for precisely the fields it renders in one round trip. gRPC exists to make *service-to-service* calls fast, strongly-typed, and streaming-capable. GraphQL puts flexibility in the client's hands (and accepts the caching and query-cost problems that follow); gRPC puts a rigid, generated contract on both sides and optimizes the pipe between them. They are rarely direct competitors: a common architecture uses GraphQL or REST at the browser-facing edge and gRPC underneath, between the backend services — and a GraphQL resolver calling a downstream service over gRPC is an entirely natural pairing.
The one weakness that shapes gRPC's whole positioning is the browser problem. Web browsers do not expose the low-level HTTP/2 framing control that gRPC needs, and JavaScript cannot manipulate raw HTTP/2 streams the way gRPC's protocol requires, so you *cannot* call a standard gRPC service directly from a web page. The workaround is gRPC-Web, a variant that speaks a browser-compatible protocol and sits behind a small proxy (often Envoy) that translates between gRPC-Web and real gRPC. It works, but it is an extra moving part and does not support every streaming mode fully. The practical consequence: gRPC is a superb choice for internal, machine-to-machine communication and an awkward one for public, browser-facing APIs, which is exactly why the industry pattern is REST/GraphQL at the edge and gRPC within.
The debuggability trade-off deserves an honest word, because it is the daily friction engineers feel with gRPC. With REST and JSON, you can open a browser or run curl, read the response with your own eyes, paste it into a colleague's chat, and generally treat the traffic as text. gRPC's binary Protobuf is opaque: you cannot eyeball it on the wire, and inspecting a request means using dedicated tooling (grpcurl, or a UI like the ones built into service meshes) that knows the schema. In exchange you get the guarantees that come from a compiled contract — you cannot typo a field name and discover it in production, because the code would not compile — but the loss of casual, human-readable inspection is real and is part of why many teams keep a REST or GraphQL facade at the boundary where humans and external partners interact, and reserve gRPC for the internal machinery where the speed and type-safety matter more than eyeballing packets. It is the same instinct as compiling a language: you trade some immediacy for a lot of safety and performance, and the trade is worth it in some places and not others.
It also helps to see how these choices coexist in a real architecture rather than compete. A typical modern system looks like a fan: at the outer edge, facing browsers, mobile apps, and third-party developers, sits REST or GraphQL — human-readable, cacheable, browser-friendly, widely tooled. Behind that edge, the internal services talk to each other over gRPC — binary, typed, streaming, fast. A GraphQL gateway's resolvers, or a REST controller's handlers, frequently *are* gRPC clients calling downstream services. So the "versus" framing is partly a false choice: the honest question is rarely "gRPC or REST for my whole system" but "which style at which layer." Get that layering right — public-friendly protocols at the edge, high-performance typed RPC in the core — and each style does the job it is actually good at.
So when should you actually reach for gRPC? The clearest wins are internal microservice-to-microservice communication in a polyglot backend, where many services in different languages call each other constantly and you want speed, guaranteed contracts, and easy code generation across all of them. It is also excellent for high-throughput, low-latency systems where JSON's size and parsing cost genuinely matter, and for anything that needs streaming — real-time feeds, chunked transfers, bidirectional sync — as a first-class capability rather than a bolt-on. Conversely, avoid it for public APIs where third-party developers expect the familiarity and tooling of REST-over-JSON, and for browser-facing endpoints where the gRPC-Web proxy is friction you may not want. Choose gRPC for the fast, typed, streaming plumbing *between* your services; choose REST or GraphQL for the flexible, cacheable, human-friendly surface you expose *to the world*. An engineer who can explain why — Protobuf and HTTP/2 for internal speed and contracts, JSON over HTTP for public reach and caching — understands not just how gRPC works, but where it belongs in a real architecture.
gRPC is a high-performance RPC framework: remote calls are written like ordinary local function calls.
You define services and messages in a .proto file using Protocol Buffers; protoc generates client and server stubs for many languages.
Requests travel over HTTP/2 as binary Protobuf — compact, fast, and multiplexed over one connection.
It supports unary calls plus client-, server-, and bidirectional streaming.
Ideal for internal microservice-to-microservice communication, but less browser-friendly than REST.
Quick quiz
What is the role of the .proto file in gRPC?
Why is gRPC well-suited to internal microservice communication but less to browsers?
REST vs GraphQL
Two ways to shape an API — resources and endpoints, or one flexible query.
HTTP/1 → HTTP/2 → HTTP/3
Three generations of the web's request protocol, each killing the last one's bottleneck.
How Kubernetes works
You declare the desired state; the cluster relentlessly makes it real.
How Apache Kafka works
A distributed commit log that decouples who produces data from who consumes it.