The goal of this project is to experiment with tokio & hyper creating an asynchronous http server that runs in a single tread.
Run the server in --release mode:
cargo run --releaseRun the server in dev mode with tracing in debug level:
RUST_LOG=example_tokio_single_thread=debug cargo runInstall cargo-watch:
cargo install cargo-watchWatch the server in dev mode with tracing in debug level:
RUST_LOG=example_tokio_single_thread=debug cargo watch -w src -x runIf wrk is available you can test the performance of the server like
this:
NOTE: First run the rust server in --release mode for performance tests
# threads: 1
# open connections: 1
# run for 10s
wrk -t1 -c1 -d10s http://127.0.0.1:3000There is also a plain nodejs http server available in ./node/server.js. You can use it to compare
the performance between the two.
# start the server
node node/server.js --port 4032
# run the benchmark
wrk -t1 -c1 -d10s http://127.0.0.1:4032Next Goals
- integrate more benchmarking tools
- support https & http2
- generate rustdoc documentation
| Crate | Description |
|---|---|
| bytes | Provides abstractions for working with bytes. |
| env_logger | A logger configured via env vars, to use with the logging facade exposed by log |
| hyper | (see examples) |
| hyper-util | Utilities for hyper |
| http-body | Asynchronous HTTP request or response body |
| http-body-util | Utilities for http-body |
| log | A lightweight logging facade. |
| pretty_env_logger | Writes to standard error with nice colored output for log levels. |
| tokio-macros | - |
| tokio | - |
| url | implementation of the URL Standard for the Rust programming language. |