Skip to main content Link Menu Expand (external link) Document Search Copy Copied

gRPC Lab

Machines in a distributed system must communicate with one another. One method of doing this is using Remote Procedure Calls (RPCs), which make communication between machines look like ordinary function calls. Effectively, RPCs abstract away the underlying serialization required for raw messaging and allow for an interaction like this:

  • A client calls remoteFileSystem->Read("rutabaga").
  • The underlying RPC library serializes this function call as a request and sends it to the server.
  • The RPC library deserializes the request on the server and runs fileSys->Read("rutabaga"), which returns a response.
  • The RPC library serializes the response, sends it to the client, and deserializes it to give the client the return value for its function call.

Effectively, this allows the client to call a function on an entirely different machine as if it was just calling any other function.


Serialization is the process of converting structures into bytes that can be sent via communication protocols like TCP, while deserialization recovers the original structures from the serialized bytes. Serialization formats specify how serialization and deserialization should take place, and allow communicating processes to understand the bytes being received from one another. For example, JSON and YAML are two common serialization formats that often find use in configuration files.

In this lab, you will be familiarizing yourself with gRPC, an open source remote procedure call (RPC) framework that uses Google’s protocol buffer serialization mechanism. You will do so by implementing a very basic key/value (KV) store, which allows clients to put keys in a server-side hash map and read them out later by making requests to the server.

For a brief rundown of how gRPC works, please read this guide. For more specifics on how gRPC works in Rust, you can take a look at this tutorial, but we will be covering the content relevant to the MapReduce homework in this lab.

Getting started

It is strongly recommended that you complete this assignment locally rather than on your VM. Compilation will be much faster, and you will not need to worry about starting up your VM and connecting to it.

If you have not yet set up a local repository, run the following commands directly on your computer (feel free to modify the first command if you would like to set up the repo in a different location):

git clone ~/code/personal # CHANGE THIS!
cd ~/code/personal
git remote rename origin personal 
git pull personal main
git remote add staff 
git pull staff main
cd lab-grpc-rs

With your repo set up, pull the staff starter code:

cd ~/code/personal
git pull staff main
cd lab-grpc-rs

If you made changes to your repo on a different (virtual) machine, make sure to run git pull personal main as well.

If you are doing the lab locally, you will need to install CMake by following the directions here. Make sure you install a relatively new version of CMake (at least 3.20.0) to ensure that you don’t run into any issues.

To check if CMake is installed correctly, run cmake --version and check if it outputs the version you expect.

If Rust is not installed, install it according to the directions here.