rwf2 / Rocket

A web framework for Rust.
https://rocket.rs
Other
24.4k stars 1.56k forks source link

I'm getting bad performance #799

Closed ghost closed 5 years ago

ghost commented 6 years ago

I'm testing Rocket master as of today with rustc 1.31.0 nightly and --release mode. I'm running the hello_world sample and I have a Rocket.toml file with workers set according to what I'm comparing with.

I read through the issue posted by Hyper devs: https://github.com/SergioBenitez/Rocket/issues/140 but as far as I can tell, Rocket performs better than Hyper. Both scale over many CPU cores, so a proper Rocket.toml configuration is essential for comparing purposes.

However, the result I get is really bad. Almost on Node.js levels, below Crystal, below Golang, below all "C servers".

I'm running Linux and I'm collecting IO benchmark results for a graph I'm plotting for demo purposes and wanted a Rust server in the graph.

Is Rocket supposed to be this slow?

SergioBenitez commented 5 years ago

You haven't provided anywhere near enough information to answer your question.

Which OS are you running? What are your machine's specifications (CPU kind, clock speed, core count, kind and quantity of RAM, operating system version/distribution)? What code/configuration are you running for node.js, crystal, golang, and Rocket? How are you benchmarking the different frameworks?

In my "hello, world!" testing, on my hardware (2 x 4 core, 16 HT, 2010 Xeon, 48GB DDR3, Debian 8) Rocket is about 36% faster than node.js/express. I haven't tested again Crystal or Golang. According to this, Rocket is faster than most Crystal/Golang web frameworks, but not all.

Still, Rocket is heavily bottlenecked by the version of Hyper it uses. I expect to see pack-leading performance when we migrate to the latest version of Hyper.

All that being said: it's incredibly unlikely that Rocket's performance will be a bottleneck for anyone. It is already > 10x faster than Django/Rails, and yet some of the largest, most trafficked websites in the world are built on these frameworks (GitHub, AirBnB, Hulu, Disqus, Bitbucket, Instagram, Pinterest). You should instead focus on how productive you can be with a given framework, and how much you think it will reduce your cognitive workload when it comes to topics of security and correctness, areas I think Rocket really shines.

ghost commented 5 years ago

Rocket is about 36% faster than node.js/express.

Exactly my point, I get similar results. I guess that answers my question...

Thanks for clearing that up.

girng commented 5 years ago

Exactly my point, I get similar results. I guess that answers my question...

haha!

Thanks for clearing that up.

😂😂🤣