RPC Demo
This repository contains instructions for trying out Apache Thrift and gRPC on
Ubuntu 14.
Using Thrift
- Install Thrift as follows (though if you want the latest version of Thrift,
you should build it from source).
sudo pip install thriftsudo apt-get install thrift-compilersudo apt-get install ipython
- Then do the following (after cloning this repository).
-
cd rpc-demo/thrift_files -
Generate the Python files with
thrift --gen py messages.thrift
- Run the code.
-
Start the server with
python server.py. -
Start the client with
python client.py. This drops you into an ipython shell. -
Enter commands in the client such as
client.SayHello("Robert")to send a message to the server process. Or
%timeit client.SayHello("Robert")to benchmark the rpc.
Using gRPC
- Install gRPC with the commands below.
sudo pip install grpciosudo apt-get install build-essential autoconf libtoolsudo apt-get install ipythongit clone https://github.com/grpc/grpc.gitcd grpcgit submodule update --initmakesudo make installsudo apt-get install protobuf-compiler(to keep setup simple, we use an old version of Protobuf)
- After that, do the following (after cloning this repository).
-
cd rpc-demo/grpc_files -
Generate the Python files with
protoc -I . --python_out=. --grpc_out=. --plugin=protoc-gen-grpc=`which grpc_python_plugin` messages.proto
- Run the code.
-
Start the server with
python server.py -
Start the client with
python client.py -
Enter commands such as
stub.SayHello(messages_pb2.HelloRequest(name="Robert"), 1)to send a message to the server process. Or
%timeit stub.SayHello(messages_pb2.HelloRequest(name="Robert"), 1)
On this page
Languages
Python88.9%Protocol Buffer8.5%Thrift2.5%
Contributors
Created June 28, 2016
Updated February 12, 2026