Skip to content

fatehss/gRPC-practice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gRPC and Protobuf practice

The goal of this repository is to get familiar with google's take on RPC calls. I'll be running a python client with a C++ server. The simple idea will be to run a function remotely that will do a nested for loop for N iterations and returns the time taken. Obviously C++ will be a lot faster than python (this was not actually the case). I'll compare and contrast the time taken between the gRPC call and the call in python.

Steps to reproduce:

Prerequisites - make sure that protoc and grpc are installed on your system.

Then you can run the setup.sh script to create and activate the venv with

  1. Run ./setup.sh and then activate venv via source venv/bin/activate
    • this will set up the venv with requirements, compile the loop.proto file using protoc, and then compile the C++ server
  2. Start the C++ server using ./server
  3. Run the python client via python python_files/client.py to see the speed difference

Example output:

(venv) fss@n007h130 GRPC-practice % python python_files/client.py
Time taken by gRPC C++ server: 1843.00 microseconds
Time taken by Python server: 6176.95 microseconds

Interestingly we see that the difference is not so large (unlike what those LinkedIn posts with balls moving horizontally would lead you to believe). Apparently this is because in the code, we are just simluating work by doing nothing. This is pretty optimized on python too, hence the relatively small speed difference of only a factor of 3 in favor of C++.

About

Practicing protobuf and grpc with a toy python client and c++ server

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors