• Stars
    star
    4,651
  • Rank 9,114 (Top 0.2 %)
  • Language
    Rust
  • License
    MIT License
  • Created over 4 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Ohayou(おはよう), HTTP load generator, inspired by rakyll/hey with tui animation.

oha (おはよう)

GitHub Actions Crates.io Arch Linux Homebrew Gitter

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 tui-rs.

demo

Installation

This program is built on stable Rust.

cargo install oha

You can optionally build oha against rustls instead of native-tls.

cargo install --no-default-features --features rustls oha

On Arch Linux

pacman -S oha

On macOS (Homebrew)

brew install oha

On Debian (Azlux's repository)

echo "deb http://packages.azlux.fr/debian/ buster main" | sudo tee /etc/apt/sources.list.d/azlux.list
wget -qO - https://azlux.fr/repo.gpg.key | sudo apt-key add -
apt update
apt install 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.

Ohayou(おはよう), HTTP load generator, inspired by rakyll/hey with tui animation.

Usage: oha [FLAGS] [OPTIONS] <url>

Arguments:
  <URL>  Target URL.

Options:
  -n <N_REQUESTS>                    Number of requests to run. [default: 200]
  -c <N_WORKERS>                     Number of workers to run concurrently. You may should increase limit to number of open files for larger `-c`. [default: 50]
  -z <DURATION>                      Duration of application to send requests. If duration is specified, n is ignored.
                                     Examples: -z 10s -z 3m.
  -q <QUERY_PER_SECOND>              Rate limit for all, in queries per second (QPS)
      --burst-delay <BURST_DURATION> Introduce delay between a predefined number of requests.
                                     Note: If qps is specified, burst will be ignored
      --burst-rate <BURST_REQUESTS>  Rates of requests for burst. Default is 1
                                     Note: If qps is specified, burst will be ignored
      --rand-regex-url               Generate URL by rand_regex crate but dot is disabled for each query e.g. http://127.0.0.1/[a-z][a-z][0-9]. Currently dynamic scheme, host and port with keep-alive are not works well. See https://docs.rs/rand_regex/latest/rand_regex/struct.Regex.html for details of syntax.
      --max-repeat <MAX_REPEAT>      A parameter for the '--rand-regex-url'. The max_repeat parameter gives the maximum extra repeat counts the x*, x+ and x{n,} operators will become. [default: 4]
      --latency-correction           Correct latency to avoid coordinated omission problem. It's ignored if -q is not set.
      --no-tui                       No realtime tui
  -j, --json                         Print results as JSON
      --fps <FPS>                    Frame per second for tui. [default: 16]
  -m, --method <METHOD>              HTTP method [default: GET]
  -H <HEADERS>                       Custom HTTP header. Examples: -H "foo: bar"
  -t <TIMEOUT>                       Timeout for each request. Default to infinite.
  -A <ACCEPT_HEADER>                 HTTP Accept Header.
  -d <BODY_STRING>                   HTTP request body.
  -D <BODY_PATH>                     HTTP request body from file.
  -T <CONTENT_TYPE>                  Content-Type.
  -a <BASIC_AUTH>                    Basic authentication, username:password
      --http-version <HTTP_VERSION>  HTTP version. Available values 0.9, 1.0, 1.1, 2.
      --host <HOST>                  HTTP Host header
      --disable-compression          Disable compression.
  -r, --redirect <REDIRECT>          Limit for number of Redirect. Set 0 for no redirection. [default: 10]
      --disable-keepalive            Disable keep-alive, prevents re-use of TCP connections between different HTTP requests.
      --ipv6                         Lookup only ipv6.
      --ipv4                         Lookup only ipv4.
      --insecure                     Accept invalid certs.
      --connect-to <CONNECT_TO>      Override DNS resolution and default port numbers with strings like 'example.org:443:localhost:8443'
      --disable-color                Disable the color scheme.
      --unix-socket <UNIX_SOCKET>    Connect to a unix socket instead of the domain in the URL. Only for non-HTTPS URLs.
  -h, --help                         Print help
  -V, --version                      Print version

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.

oha <-z or -n> -c <number of concurrent connections> -q <query per seconds> --latency-correction --disable-keepalive <target-address>
  • --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.

oha -n 10 --burst-delay 2s --burst-rate 4

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.

oha --rand-regex-url http://127.0.0.1/[a-z][a-z][0-9]

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 incovenient if url's dots are interpreted as regex's dot.

Optionaly 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.
  • Output like CSV or JSON format.
  • Improve histogram in summary output
    • It uses very simple algorithm now.

More Repositories

1

Accepted

A terminal text editor to be ACCEPTED
Rust
111
star
2

competitive-rust-snippets

My Rust snippets for competitive programming
Rust
79
star
3

cargo-snippet

A snippet extrator for competitive programmers
Rust
74
star
4

kiro

A minimal text editor in Rust
Rust
31
star
5

rene

WIP Vulkan Raytracing renderer entirely written in Rust
Rust
18
star
6

http-mitm-proxy

A HTTP proxy server library intended to be a backend of application like Burp proxy
Rust
15
star
7

vst-rs-example-iced

An examle for vst-rs with GUI with iced
Rust
12
star
8

ash-raytracing-example

An example of KHR raytracing using ash and rust-gpu.
Rust
10
star
9

egglog-language-server

A language server and VScode extension for egglog
Rust
7
star
10

myc

my c compiler
Rust
5
star
11

zenn-content

Rust
5
star
12

pingora_bench

Rust
4
star
13

vst-rs-example-egui

Rust
3
star
14

fluid-animations

My codes for The Art of Fluid Animation
Rust
3
star
15

blackbody

Temperature to blackbody color
Rust
3
star
16

apd

Simple fluid simulation library supports Advect, Project and Diffuse operations.
Rust
3
star
17

chainer-text-generator

Python
3
star
18

hlsl-grimoire-sample-wgpu

Samples written in Rust for "HLSL シェーダーの魔導書 シェーディングの基礎からレイトレーシングまで"
Rust
3
star
19

vst_plugin_parameters_derive

derive macro for vst::plugin::PluginParameters in vst-rs
Rust
2
star
20

vst-rs-example-conrod

An examle for vst-rs with GUI with conrod
Rust
2
star
21

calc

https://github.com/PacktPublishing/Learn-LLVM-12/tree/master/Chapter03/calc in Rust
Rust
2
star
22

haneru

Rust
2
star
23

RNN-hearthstone-card-generator-web

hearthstone card generator using RNN
HTML
2
star
24

rukako

WIP GPU Renderer in Rust
Rust
1
star
25

Cursion

A pure Rust, like Curses, cursor optimization library to avoid flickering in terminal.
Rust
1
star
26

sound-programming-study

A personal playground for [Pythonではじめる音のプログラミング](https://www.ohmsha.co.jp/book/9784274228995/)
Rust
1
star
27

raspi-k8s-itamae-recipi

An itamae recipi to setup kubeadm for Raspberry pi
Ruby
1
star
28

hash_benchmark

Rust
1
star
29

rew

Rust
1
star
30

codecrafters-sqlite-rust

Rust
1
star
31

https-mitm

Rust
1
star
32

raytracing-1w

My codes for Ray Tracing in One Weekend Book Series.
Rust
1
star
33

vanion

Rust
1
star
34

bitset-fixed

Bitset for DP
Rust
1
star
35

nstrm

Streem like language
Go
1
star
36

whisper_volume

Rust
1
star
37

read_to_char_vec_benchmark

Rust
1
star
38

window_ime

A library to obtain IME access from a `raw-window-handle`
Rust
1
star
39

oha-538

https://github.com/hatoo/oha/issues/538
Rust
1
star
40

cs6120

My attempts to https://www.cs.cornell.edu/courses/cs6120/2020fa/self-guided/
Rust
1
star