Click👆:Linux Tech Enthusiast,follow me!!!
OHA is a lightweight and high-performance HTTP load testing tool developed in Rust, featuring a simple terminal user interface (TUI) and rich functionality.
1. Core Features
1.High Performance and Asynchronous Support
OHA is developed based on Rust’s asynchronous runtime library <span>tokio</span>
, utilizing multithreading and an event-driven model to achieve high concurrency requests, effectively simulating high-load pressure in real scenarios.
2.Real-time TUI Interface
Provides a dynamically updated text user interface that displays key metrics such as request success rate, latency distribution (minimum/maximum/average/median), throughput (QPS), and error rate in real-time, allowing users to intuitively monitor the load testing process.
3.Flexible Request Configuration
•Supports custom HTTP methods, request headers, request bodies (string or file), and timeout settings.•Provides dynamic URL generation capabilities (via regular expressions or file reading), suitable for multi-path load testing scenarios.•Supports HTTP/1.1 and HTTP/2 protocols, and can configure proxy servers and basic authentication.
4.Accurate Statistical Reports
Generates detailed JSON format reports, including latency distribution histograms, status code statistics, error type classifications, etc., facilitating subsequent analysis and optimization.
5.Request Traffic Control
Supports limiting requests per second using <span>--qps</span>
or setting burst request intervals with <span>--burst-delay</span>
to simulate more complex traffic patterns.
2. Installation Methods
OHA supports cross-platform installation, as follows:
•Linux:
•Arch-based: <span>yay -S oha</span>
(via AUR). •Debian-based: Add the Azlux repository and use <span>apt-get install oha</span>
.
•macOS: Install via Homebrew using <span>brew install hatoo/tap/oha</span>
.•Windows: Use the winget command <span>winget install oha</span>
.•Universal Method: Install via <span>x-cmd</span>
cross-platform tool using <span>x-cmd install oha</span>
.
3. Basic Usage Examples
1.Simple Load Testing
oha http://example.com -c 100 -n 5000
•<span>-c 100</span>
: Set 100 concurrent connections.•<span>-n 5000</span>
: Total request count is 5000.
2.Continuous Load Testing and Traffic Control
oha http://api.example.com -z 60s --qps 1000
•<span>-z 60s</span>
: Run continuously for 60 seconds.•<span>--qps 1000</span>
: Limit requests per second to 1000.
3.Complex Request Configuration
oha -m POST -H "Content-Type: application/json" -d '{"key":"value"}' http://api.example.com/data
•Send a POST request with a JSON request body and custom header.
4. Performance Advantages
According to benchmark tests, OHA is approximately 1.3 times faster than the <span>hey</span>
tool written in Go under the same conditions, demonstrating Rust’s efficiency in concurrent processing. For example, in local server tests, OHA had an average response time of 10.8 ms, while <span>hey</span>
had 14.3 ms.
5. Applicable Scenarios
1.Development Debugging Quickly verify the stability and performance bottlenecks of API interfaces.2.Production Environment Load Testing Simulate real traffic with high concurrency to assess the server’s maximum processing capacity.3.Real-time Monitoring and Optimization Dynamically adjust parameters using TUI to observe system response changes, assisting in performance tuning.
6. Comparison with Other Tools
•vs. wrk/ab: OHA’s TUI interface and dynamic URL support make it easier to use, while wrk relies on Lua scripts for complex configurations.•vs. hey: OHA offers better performance and provides richer real-time data displays.
Visit the GitHub repository[1] for documentation and source code.
References
<span>[1]</span>
GitHub repository: https://github.com/hatoo/oha
Looking forward to your
sharing
likes
views