in πŸ““ Notes


Table of Contents

2 min read

gRPC (gRPC Remote Procedure Calls) is a modern Remote Procedure Call mechanism, similar to traditional RPC, but developed with cloud services in mind. It was started in 2015 by Google and it is an open source project.

This implementation is built on top of HTTP/2, TLS and TCP protocols. Besides, it provides implementations for many programming languages.

For its IDL, it uses Protocol Buffers. The lower level layers of gPRC do not depend on the IDL so, in theory, it would be possible to use other alternatives to protocol buffers.

“Hello World” example

Protocol Buffer definition:

message HelloRequest {
  string name = 1;
  repeated string hobbies = 2;

message HelloResponse {
  string greeting = 1;

service HelloWorldService {
  rpc greeting(HelloRequest) returns (HelloResponse);

Server code (Java):

public class HelloServer {
  public static void main(String[] args) throws Exception {
    // ...
    final int port = Integer.parseInt(args[0]);
    final BindableService impl = new HelloWorldServiceImpl();

    Server server = ServerBuilder


public class HelloWorldServiceImpl extends HelloServiceGrpc.HelloServiceImplBase {

  public void greeting(Hello.HelloRequest request, StreamObserver<Hello.HelloResponse> responseObserver) {
    Hello.HelloResponse response = Hello.HelloResponse
      .setGreeting("Hello " + request.getName())


Client code (Java):

final ManagedChannel channel = ManagedChannelBuilder
  .usePlainText() // Unsecured channel

HelloServiceGrpc.HelloServiceBlockingStub stub = HelloServiceGrpc.newBlockingStub(channel);

Hello.HelloRequest request = Hello.HelloRequest.newBuilder()

Hello.HelloResponse response = stub.greeting(request);


Or if you don't know what a response is, you can always write a webmention comment (you don't need to know what that is).