3 ms·
For the web server... 3.6mb file using hyper, not the leanest but one of the more popular options. extern crate hyper; use hyper::Server; use hype
by tracker1 6y ago
For the web server... 3.6mb file using hyper, not the leanest but one of the more popular options.
extern crate hyper;
use hyper::Server;
use hyper::server::Request;
use hyper::server::Response;
fn hello(req: Request, res: Response) {
let response = format!("Hello from {}!", req.remote_addr.ip());
res.send(response.as_bytes()).unwrap();
}
fn main() {
Server::http("127.0.0.1:3000").unwrap()
.handle(hello).unwrap();
}
Output from wrk -t8 -c400 -d60s http://localhost:3000/ http://localhost:3000/
Running 1m test @ http://localhost:3000/
8 threads and 400 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 173.31us 88.10us 0.98ms 65.18%
Req/Sec 35.06k 13.46k 45.48k 74.99%
8383194 requests in 1.00m, 775.50MB read
Socket errors: connect 0, read 0, write 229, timeout 0
Requests/sec: 139487.00
Transfer/sec: 12.90MB
According to top, rust_http is using about 2.8mb ram, 630% cpu, and wrk is using 700k and 370% cpu.
Though I'm on completely different hardware, but the thing definitely screams...
For reference: AMD Ryzen R9 3950X, 64GB DDR4@3200(CL18) under WSL2-Ubuntu (Windows 10 insiders)