Rust vs GoLang on http/https/websocket/webrtc performance

Here, by GoLang, we are using GoLang stdlib (http, https, websocket) + pion (webrtc).

By Rust, you can use any crate that has > 100k downloads.

For these tasks that are network heavy (the most compute heavy part is probably the encryption / decryption), is there any reason to believe that optimized "normal Rust" beats optimized "normal GoLang" by a factor of more than 10% ?

Here, "normal" means the two constraints above for GoLang / Rust.

Beats in what? GoLang will probably be less stable in speed, due to the GC, so, e.g., peak RPS might be better for GoLang, while the average one - for Rust.


Like Python performance, it'll probably depend greatly on how much of it ends up being done in a library that's actually written in C anyway -- depending how you write it, it wouldn't be all that surprising if both Rust and Go ended up using the same OpenSSL library, for example.


Good question. I was thinking both latency & throughput. Given network latency is already ~ 50ms, an additional ~20ms of lag won't be too bad, so perhaps a measurement of:

while ensuing < 20ms lag in 95% of the situation, what is the maximal throughput can we achieve

I don't know about SSL, but I am 99% sure that GoLang's http server, https server (minus SSL), websocket server, and webrtc server are all pure GoLang.

Reminder that this leads to that set of benchmarks where they do things like not even look at the HTTP method, since that's slower, even in the supposedly-"realistic" ones.

TBH, if you're not convinced that you really need rust for this stuff, then you can probably do it in Go/Java/C# just fine. As a rule of thumb, it's usually easy to write something with the same throughput at the cost of 2× CPU and 2× RAM than rust in those languages, and a bit of work (and sometimes non-idiomatic code) can improve that a bunch without too much work.

If you're just running it on a few servers, you can just pay for more hardware and not worry about it. But you can also see the DropBox examples for it being well worth it to get the better performance and reliability once it's critical enough to the business and high enough scale.

1 Like

Go uses its own cryptography library (crypto package - crypto - written in Go.

Here is an article that was linked some time ago from This Week in Rust 379:

It might interest you.


@bes : Thanks for sharing the article. I found it very informative:

throughput, p50, p90 similar, but p99 quite different

Even Java is faster than Golang ,
Why do you think Rust isn't ?!

For real project when you get a library from github and almost all github golang library use interface{ }
( because golang don't support generic ) then there is real benchmark.

1 Like

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.