Tonic performance issue

Hi.

This article show benchmark result of
golang vs rust tonic and golang is big winner,

I read in somewhere async_trait does heap allocation per function call , and tonic use async_trait

Does may this be reason of performance issue ??

Comparing Rust performance like this is quite a waste of time since performance is usually related to your application and not the transport. Tonic performs just or even better in the p99 than go does in general.

Here is an example of someone going from go to rust and seeing much better performance Why Discord is switching from Go to Rust

This article is about using rust code inside Elixir (NIF) not related to Tonic !!!

I know Rust is faster
I know application layer is more important

BUT we compare because we want to have
best as possible grpc framework.
this is true of community.

you said tonic p99 is faster,
i like to see that benchmark.

These are the two graphs being referred to:

(Total Reponse Time in Milliseconds. Lower is better)

(Throughput (Requests/second). Higher is better)


One possible explanation for the performance difference is that grpc-go has probably had an order of magnitude more developer-hours put into it than tonic, and therefore more time has been spent optimising performance.

Quite a lot of cloud stuff is written in Go while there aren't as many cloud applications written in Rust, so the "market forces" are definitely there to make grpc-go as fast as possible.

It might also just be that the way Go is naturally more amenable to writing the sort of high performance asynchronous code that you want in this benchmark (the go runtime may be more efficient than tokio under this sort of load, switching cost between stackful vs stackless tasks, more performant low level libraries, better defaults, different sets of compiler optimisations, etc.). We all love Rust, but you do need to accept the possibility that other languages/frameworks may be better for certain applications.

There are many definitions of "best". For you, that might be "has the most throughput for a simple hello world endpoint", while for others that may mean

  • lets you write the most ergonomic code
  • is not opinionated and doesn't force me to rewrite my codebase in a certain way, or
  • is robust in the face of error conditions and dodgy input

I'm not writing the next Facebook so the chances that I'll be receiving 40,000+ requests per seconds on a single server are pretty low. For me, I care more about robustness and productivity/ease of writing code because it means less 3am pager messages and faster iteration cycles.

1 Like

thanks for take your time.
your answer is correct and increased my info.

I love rust.
i worked with Erlang/Elixir for 4 years and i wrote 2 scalable application
i worked with Akka for 2 years and wrote a IOT application

and the end i love Rust because it is perfect as possible.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.