- Install deps and compile
$ mix do deps.get, compile
- Run the server
$ mix grpc.server
- Run the client script
$ mix run priv/client.exs
- Modify the proto
priv/protos/helloworld.proto
- Install
protoc
here - Install
protoc-gen-elixir
mix escript.install hex protobuf
- Generate the code:
$ protoc -I priv/protos --elixir_out=plugins=grpc:./lib/ priv/protos/helloworld.proto
Refer to protobuf-elixir for more information.
Change the config to:
config :grpc, start_server: true
Using ghz
$ MIX_ENV=prod iex -S mix
# Now cowboy doesn't work well with concurrency in a connection, like --concurrency 6 --connections 1
$ ghz --insecure --proto priv/protos/helloworld.proto --call helloworld.Greeter.SayHello -d '{"name":"Joe"}' -z 10s --concurrency 6 --connections 6 127.0.0.1:50051
# The result is for branch improve-perf
Summary:
Count: 124239
Total: 10.00 s
Slowest: 18.85 ms
Fastest: 0.18 ms
Average: 0.44 ms
Requests/sec: 12423.71
# Go
Summary:
Count: 258727
Total: 10.00 s
Slowest: 5.39 ms
Fastest: 0.09 ms
Average: 0.19 ms
Requests/sec: 25861.68