Skip to content

build and test two gRPC servers, one in golang and another in Python

Notifications You must be signed in to change notification settings

icoman/benchmark-grpc-py-go

Repository files navigation

Benchmark gRPC with golang and Python

Here we build and test two gRPC servers, one in golang and another in Python.

The servers implements just one function, Test1.

A proto file define Request and Response message from Test1 function:

syntax = "proto3";


option go_package = ".;service1";

service MyRPC1 {
    // just one function inside RPC server
    rpc Test1(Benchmark) returns(Response){}

}

message Response {
    string text = 1; // server response
    uint32 crc32 = 2; // computed crc32 of received buffer
}

message Benchmark {
    string name = 1; // benchmark name
    bytes buffer = 2; // benchmark buffer
}

The protoc compiler generate "stub files" used to build the code.

The code import the "stub files", then the server implement Test1 function and the client call the Test1 function.

There are batch files (for Windows) used to generate "stub files" and to call the servers and clients, but the recipe also works in Linux with some minor changes.

The servers can use an OpenSSL certificate, but the user authentification is not implemented.

The servers compute crc32 of received buffer and return it to client, the clients also compute crc32 of buffer and verify it.

The Python implementation works on both Python 2.7 and Python 3.8

Calling the go server:

SET HOST=localhost:6002
cd go-server
start "go gRPC server secure on %HOST%" go run . -host %HOST% -secured

go server

Both, go and py, clients call go server with batch size 2048 KB:

SET HOST=localhost:6002
SET BS=2048
SET N=5
title Test go server secured - %HOST%
cd go-client
go run . -host %HOST% -bs %BS% -n %N% -secured
cd ..\py-client-server
python client.py -host %HOST% -bs %BS% -n %N% -secured
pause

go and py client call go server

Calling the python server:

SET HOST=localhost:6004
start "py gRPC server secure on %HOST%" python server.py -host %HOST% -secured

py server

Both, go and py, clients call py server with batch size 2048 KB:

SET HOST=localhost:6004
SET BS=2048
SET N=5
title Test py server secured - %HOST%
cd go-client
go run . -host %HOST% -bs %BS% -n %N% -secured
cd ..\py-client-server
python client.py -host %HOST% -bs %BS% -n %N% -secured
pause

go and py client call py server

About

build and test two gRPC servers, one in golang and another in Python

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published