poem-web / poem

A full-featured and easy-to-use web framework with the Rust programming language.
Apache License 2.0
3.61k stars 295 forks source link

how to optimize Poem's performance (Req/sec)? #610

Open rxdiscovery opened 1 year ago

rxdiscovery commented 1 year ago

Hello,

I find Poem a very ergonomic framework, I've even migrated several projects to Poem, mainly because it offers very good support for OpenAPI 3, but there is one small point that bothers me, it can be optimized to rival the TOP 3 web frameworks (Req/sec performance) that dominate the Rust universe. it's in the TOP 10, which is already a very good ranking, but the difference with the TOP 3 is approximately ~15,000 Req/sec.

https://web-frameworks-benchmark.netlify.app/result?asc=0&l=rust&order_by=level512

my question is, how to optimize Poem to gain a little performance :

I'd like to participate in the optimization of this beautiful framework, the first thing I notice is that Poem doesn't let you configure the number of Workers, like ActixWeb for example. Is there any way of adding this feature?

in any case, you've done a great job, and the beauty of this framework fills the small performance gap.

sunli829 commented 1 year ago

I believe the gap comes from the async-trait, which requires boxing every call to an async method.

rxdiscovery commented 1 year ago

I believe the gap comes from the async-trait, which requires boxing every call to an async method.

do you think rust "1.74" with native support for async traits will have a positive impact on performance?

sunli829 commented 1 year ago

absolutešŸ˜