tomaka / rouille

Web framework in Rust
Apache License 2.0
1.12k stars 106 forks source link

Option to run using thread pool #167

Closed jaemk closed 6 years ago

jaemk commented 6 years ago

Since we're talking breaking changes (#165), what are your opinions on adding an option to process requests in a thread pool? The default still being unlimited thread:::spawns. The Server struct could also be made more "builder-y" in the process.

coder543 commented 6 years ago

I definitely wonder what the performance impact of using a threadpool like Rayon would be. It could actually negatively impact performance since rouille is synchronous and jobs could suffer starvation as the workers are busy waiting on the network... not actually using the processor at all. But, if the requests are short enough, it might speed things up since the overhead of spawning a new thread is removed.

However, I would kind of just like to see 2.0 go ahead and get released.

jaemk commented 6 years ago

I'd also like to see 2.0 released soon. This could always be implemented without any breaking changes, leaving current Server methods unchanged.

I do think it'd be an option worth adding though. For long running requests, the current model certainly ensures availability. I hacked in an optional threadpool last night and some basic load tests show a 2x performance increase for basic requests (that don't touch a database), and equal performance for database-limited queries.