Learn gRPC

High-performance RPC framework using Protocol Buffers over HTTP/2

16 lessons · 3 hours · 4 levels · covers gRPC gRPC 1.7x (grpc-js 1.14), proto3

gRPC is an open-source remote procedure call framework: you define services and messages in Protocol Buffers, generate typed clients and servers for many languages, and call remote methods like local functions over HTTP/2. It is the standard for internal service-to-service APIs in microservice systems, offering compact binary messages, streaming, deadlines and rich tooling.

Before you start

gRPC builds on these; the tree links to the exact lessons you need.

How deep do you want to go?

1. EssentialsRead and write simple code, do the everyday basics5 lessons · 55 min in total
2. PracticalUse it productively at work, with the usual idioms9 lessons · 2 hours in total
3. AdvancedThe less common features, performance and trade-offs13 lessons · 3 hours in total
4. ExpertInternals and the edge cases experts know16 lessons · 3 hours in total

The gRPC tree

gRPCWhat gRPC isWhat gRPC isProtobuf messagesProtobuf messagesServices and the four RPC kindsServices and the fourRPC kindsA server and client in Node.jsA server and client inNode.jsStatus codes and errorsStatus codes anderrorsStreaming RPCsStreaming RPCsDeadlines and cancellationDeadlines andcancellationMetadata, TLS and authenticationMetadata, TLS andauthenticationEvolving protobuf schemas safelyEvolving protobufschemas safelynpm and package.jsonnpm andpackage.jsonStreams: reading and writing in chunksStreams: reading andwriting in chunks
Essentials and Practical shown (9 of 16 lessons); the full list is below. Click a lesson to read it.

All 16 lessons, in order

Core ideas

  1. What gRPC is · Essentials · 8 min

    Contract-first RPC: define services in .proto files, generate stubs, and call remote methods over HTTP/2.

Protocol Buffers

  1. Protobuf messages · Essentials · 12 min

    Define proto3 messages with scalar, repeated, map, enum and nested fields, each identified by a field number.

  2. Services and the four RPC kinds · Essentials · 10 min

    Declare service methods as unary, server-streaming, client-streaming or bidirectional-streaming RPCs.

  3. Evolving protobuf schemas safely · Practical · 12 min

    Change .proto files without breaking deployed clients: add fields, reserve removed numbers, and use oneof wisely.

Clients and servers

  1. A server and client in Node.js · Essentials · 15 min

    Load a .proto with @grpc/proto-loader, implement a unary handler with @grpc/grpc-js, and call it from a client stub.

  2. Status codes and errors · Essentials · 10 min

    Fail calls with the right gRPC status code and details, and handle errors on the client by code rather than message.

Streaming and call control

  1. Streaming RPCs · Practical · 15 min

    Implement server, client and bidirectional streams with grpc-js call objects that behave like Node streams.

  2. Deadlines and cancellation · Practical · 12 min

    Set a deadline on every call, propagate it to downstream calls, and stop work when a call is cancelled.

Running in production

  1. Metadata, TLS and authentication · Practical · 15 min

    Send headers as metadata, secure channels with TLS, and attach per-call tokens with call credentials.

  2. Interceptors · Advanced · 15 min

    Add logging, auth, metrics and retries around every call with client and server interceptors.

  3. Health checks, reflection and grpcurl · Advanced · 12 min

    Expose the standard health service, enable server reflection, and debug calls from the terminal with grpcurl.

  4. Connections, keepalive and load balancing · Advanced · 15 min

    Understand why long-lived HTTP/2 connections break naive load balancing, and fix it with L7 proxies or client-side balancing.

  5. gRPC-Web, Connect and REST gateways · Advanced · 12 min

    Reach gRPC services from browsers and REST clients using gRPC-Web, the Connect protocol or HTTP/JSON transcoding.

Wire format and tuning

  1. Wire format: protobuf bytes and HTTP/2 frames · Expert · 15 min

    Decode protobuf tags, varints and length-delimited fields, and see how gRPC frames messages, headers and trailers on HTTP/2.

  2. Retries, hedging and service config · Expert · 15 min

    Configure transparent retries, retry policies and hedging through service config, and keep retries from overloading a system.

  3. Flow control and performance tuning · Expert · 15 min

    Tune HTTP/2 flow control, message sizes, compression and concurrency limits, and measure before changing defaults.