thruster-rs / Thruster

A fast, middleware based, web framework written in Rust
MIT License
1.06k stars 47 forks source link

Improve Thruster Server struct performance #120

Closed trezm closed 3 years ago

trezm commented 5 years ago

Would love to get the home-grown implementation of an http encoder/decoder more in line with hyper's perf.

For perf focused users, you can now easily use Hyper as the backend, but it would be nice to be on level playing fields in the future.

Austaras commented 4 years ago

No idea why, but in my machine thruster's own server is around 50% faster than using hyper as backend

trezm commented 4 years ago

That's fascinating! Are you running in release? I wonder if we're using some non-performant hyper method calls. You're just using the "out of the box" Hyper server and Thruster server, correct?

Austaras commented 4 years ago

Well, it seems likely to be later case. I ran basic and hyper example in this repo both in release, and got 30k/22k rps

trezm commented 4 years ago

Very interesting, I'll have to do some testing to dig into why. The homegrown server should be faster, but not by that big a margin!

trezm commented 4 years ago

@Austaras, would you mind sharing the command you're using to benchmark each? I get much more comparable results between the thruster and hyper backends:

Thruster: 3316177 requests in 30.10s Hyper: 3071149 requests in 30.10s

If you're on a Macbook Pro, it might be getting thermally throttled if you run the compiles in series.

Austaras commented 4 years ago

Just a simple wrk. So I'm using a quite powerful desktop on Linux(I got around 3x rps to your result) and only test for 10 seconds, maybe these factors could affect the result.