We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I wrote a simple code to serve static files, but its performance is too slow. Did I miss any configuration or code ?
CPU: i5-10400
use poem::{endpoint::StaticFilesEndpoint, handler, listener::TcpListener, web::Path, Route, Server}; #[handler] fn hello(Path(name): Path<String>) -> String { format!("hello: {}", name) } #[tokio::main] async fn main() -> Result<(), std::io::Error> { let endpoint = StaticFilesEndpoint::new("./static").show_files_listing(); let app = Route::new().nest("/static", endpoint); Server::new(TcpListener::bind("0.0.0.0:8889")) .run(app) .await }
testing read a ~5Mb picture, The req/sec is 66.26 , cpu usage is about ~700%
wrk -t8 -c500 -d30s http://192.168.31.28:8889/static/image/0a2cf6866a19cb2546ca8827e59997aa.png Running 30s test @ http://192.168.31.28:8889/static/image/0a2cf6866a19cb2546ca8827e59997aa.png 8 threads and 500 connections Thread Stats Avg Stdev Max +/- Stdev Latency 0.00us 0.00us 0.00us nan% Req/Sec 18.41 15.58 90.00 75.46% 1988 requests in 30.00s, 8.91GB read Socket errors: connect 251, read 113, write 0, timeout 1988 Requests/sec: 66.26 Transfer/sec: 304.00MB
Test another web framework ntex
ntex
use ntex::web; use ntex_files as fs; #[rustfmt::skip] #[ntex::main] async fn main() -> std::io::Result<()> { web::HttpServer::new(|| { web::App::new() .service(fs::Files::new("/static", "./static").show_files_listing()) }) .bind("0.0.0.0:8889")? .run() .await }
The req/sec is 645.02 , cpu usage is about ~850%
wrk -t8 -c500 -d30s http://192.168.31.28:8889/static/image/0a2cf6866a19cb2546ca8827e59997aa.png Running 30s test @ http://192.168.31.28:8889/static/image/0a2cf6866a19cb2546ca8827e59997aa.png 8 threads and 500 connections Thread Stats Avg Stdev Max +/- Stdev Latency 375.71ms 69.00ms 1.08s 66.19% Req/Sec 81.43 39.01 333.00 70.89% 19391 requests in 30.06s, 80.84GB read Socket errors: connect 251, read 104, write 0, timeout 0 Requests/sec: 645.02 Transfer/sec: 2.69GB
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I wrote a simple code to serve static files, but its performance is too slow. Did I miss any configuration or code ?
CPU: i5-10400
testing read a ~5Mb picture, The req/sec is 66.26 , cpu usage is about ~700%
Test another web framework
ntex
The req/sec is 645.02 , cpu usage is about ~850%
The text was updated successfully, but these errors were encountered: