oha (おはよう)
oha is a tiny program that sends some load to a web application and show realtime tui inspired by rakyll/hey.
This program is written in Rust and powered by tokio and beautiful tui by ratatui.
Installation
This program is built on stable Rust, with both make
and cmake
prerequisites to install via cargo.
cargo install oha
You can optionally build oha against native-tls instead of rustls.
cargo install --no-default-features --features rustls oha
You can enable VSOCK support by enabling vsock
feature.
cargo install --features vsock oha
On Arch Linux
pacman -S oha
On macOS (Homebrew)
brew install oha
On Windows (winget)
winget install hatoo.oha
On Debian (Azlux's repository)
echo "deb [signed-by=/usr/share/keyrings/azlux-archive-keyring.gpg] http://packages.azlux.fr/debian/ stable main" | sudo tee /etc/apt/sources.list.d/azlux.list
sudo wget -O /usr/share/keyrings/azlux-archive-keyring.gpg https://azlux.fr/repo.gpg
apt update
apt install oha
Containerized
You can also build and create a container image including oha
Then you can use oha directly through the container
Profile-Guided Optimization (PGO)
You can build oha
with PGO by using the following commands:
And the binary will be available at target/[target-triple]/pgo/oha
.
Platform
- Linux - Tested on Ubuntu 18.04 gnome-terminal
- Windows 10 - Tested on Windows Powershell
- MacOS - Tested on iTerm2
Usage
-q
option works different from rakyll/hey. It's set overall query per second instead of for each workers.
<URL> Target
)
)
JSON output
oha
prints JSON output when -j
option is set.
The schema of JSON output is defined in schema.json.
Benchmark
Performance Comparison
We used hyperfine
for benchmarking oha
against rakyll/hey
on a local server. The server was coded using node. You can start the server by copy pasting this file and then running it via node. After copy-pasting the file, you can run the benchmark via hyperfine
.
- Copy-paste the contents into a new javascript file called app.js
const http = require;
const server = http.;
server.;
- Run
node app.js
- Run
hyperfine 'oha --no-tui http://localhost:3000' 'hey http://localhost:3000'
in a different terminal tab
Benchmark Results
Benchmark 1: oha --no-tui http://localhost:3000
- Time (mean ± σ): 10.8 ms ± 1.8 ms [User: 5.7 ms, System: 11.7 ms]
- Range (min … max): 8.7 ms … 24.8 ms (107 runs)
Benchmark 2: hey http://localhost:3000
- Time (mean ± σ): 14.3 ms ± 4.6 ms [User: 12.2 ms, System: 19.4 ms]
- Range (min … max): 11.1 ms … 48.3 ms (88 runs)
Summary
In this benchmark, oha --no-tui http://localhost:3000
was found to be faster, running approximately 1.32 ± 0.48 times faster than hey http://localhost:3000
.
Tips
Stress test in more realistic condition
oha
uses default options inherited from rakyll/hey but you may need to change options to stress test in more realistic condition.
I suggest to run oha
with following options.
-
--disable-keepalive
In real, user doesn't query same URL using Keep-Alive. You may want to run without
Keep-Alive
. -
--latency-correction
You can avoid
Coordinated Omission Problem
by using--latency-correction
.
Burst feature
You can use --burst-delay
along with --burst-rate
option to introduce delay between a defined number of requests.
In this particular scenario, every 2 seconds, 4 requests will be processed, and after 6s the total of 10 requests will be processed.
NOTE: If you don't set --burst-rate
option, the amount is default to 1
Dynamic url feature
You can use --rand-regex-url
option to generate random url for each connection.
Each Urls are generated by rand_regex crate but regex's dot is disabled since it's not useful for this purpose and it's very inconvenient if url's dots are interpreted as regex's dot.
Optionally you can set --max-repeat
option to limit max repeat count for each regex. e.g http://127.0.0.1/[a-z]* with --max-repeat 4
will generate url like http://127.0.0.1/[a-z]{0,4}
Currently dynamic scheme, host and port with keep-alive are not works well.
Contribution
Feel free to help us!
Here are some issues to improving.
- Write tests
- Improve tui design.
- Show more information?
- There are no color in realtime tui now. I want help from someone who has some color sense.
- Improve speed
- I'm new to tokio. I think there are some space to optimize query scheduling.