This project is a demonstration of the Axum web application framework and its performance capabilities. It utilizes the Rust programming language to test the performance and efficiency of Axum.
- Rust 1.74 or later
To set up this project on your machine, first, you need to install Rust. Here are the steps to do that:
- Install Rustup: Rustup is a toolchain installer for the Rust programming language. You can install it by running the following command in your terminal:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
This will also install Rust, Cargo (Rust's package manager), and other necessary tools for Rust.
- Verify the installation: Once the above command completes its execution, restart your terminal and then run the following command:
rustc --version
- Create a new project using this sample codes ( Cargo.toml and main.rs )
cargo new http-req-count
This project is primarily aimed at testing the performance of the Axum framework. The demo project sets up a simple HTTP API with a "/up" route that increments a counter held in shared application state. The demo highlights some of the core capabilities of the Axum framework, especially as it comes to managing shared application state across routes in the context of a multithreaded server environment. This performance testing project is a great way to explore the features of the Axum framework and get an understanding of how it performs under different workloads.
- Before starting the load test, ensure your application is running. You can start your application (make sure you're in the right directory) with:
cargo run
- Open a new terminal window.
- Start a wrk test with the following command:
wrk -t12 -c400 -d30s http://127.0.0.1:3000/up
This instructs wrk to use 12 threads, keep 400 HTTP connections open, and run the test for 30 seconds. You should adjust these according to your requirements or hardware capabilities.
After the test finishes, wrk will give you a report with details about how many HTTP requests were made, latency information, the number of requests per second, and more.
PLEASE NOTE: Load testing an application can put significant stress on your server and network. ONLY do this on servers and networks you control, and ONLY after understanding the implications. This can have implications on your network and service availability. Use responsibly.