# 1. Install the protoc plugin for Go
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
# 2. Generate code from your .proto file
protoc --go_out=. --go-grpc_out=. service.proto
# 3. Implement the generated interface
type server struct{ pb.UnimplementedGreeterServer }
func (s *server) SayHello(ctx context.Context, r *pb.HelloRequest) (*pb.HelloReply, error) {
return &pb.HelloReply{Message: "Hello, " + r.Name}, nil
}
Your First gRPC Service in 30 Minutes
gRPC can feel daunting when you first encounter it: a new IDL, generated code, HTTP/2 transport, and a different mental model from REST. This guide strips away the complexity and walks you through building a working gRPC service from scratch, with enough explanation along the way to understand what each piece does.
Prerequisites
You will need the Protocol Buffer compiler (protoc) and the gRPC plugin for your language of choice. For Go, install protoc-gen-go and protoc-gen-go-grpc. For Python, install grpcio-tools via pip. Node developers can use the @grpc/proto-loader package without a compilation step. All of these tools are free and well-documented in the official gRPC quickstart guides.
Defining Your Service
Everything in gRPC starts with a .proto file. You define your messages (request and response types) and your service (a collection of RPC methods) in the Protocol Buffer language. The syntax is concise and readable. A simple key-value store service might define Get and Put methods, each with straightforward message types containing a string key and bytes value. Once your proto file is correct, protoc generates the boilerplate so you never write serialization code by hand.
Implementing the Server
The generated code provides an interface with one method per RPC you defined. Your job is to implement that interface with real business logic. In Go, this means writing a struct that satisfies the generated interface and registering it with a grpc.Server instance. In Python, you subclass the generated servicer class. The framework handles all the network plumbing: accepting connections, parsing messages, calling your handler, and serializing the response.
Writing the Client
The generated client stub gives you a method for each RPC that looks like a regular function call. Pass in the request message, get back the response (and an error). Under the hood, the stub serializes the request with Protocol Buffers, sends it over an HTTP/2 connection, waits for the response frames, and deserializes the reply. Deadlines, metadata, and call credentials attach cleanly to the context or call options without cluttering your business logic.
Running and Testing
Start the server, run the client, and observe your first successful RPC. From there, explore grpcurl for command-line testing (it speaks gRPC the way curl speaks HTTP), and the gRPC server reflection API for dynamic introspection. Unit testing gRPC services is straightforward: instantiate the server implementation and call its methods directly, without standing up a network connection at all.
What to Learn Next
Once your first service is working, the natural next steps are error handling with gRPC status codes, deadline propagation across service boundaries, and adding authentication with TLS and token-based credentials. Each topic has dedicated deep-dive articles in the gRPC Blog library.