An open API service indexing awesome lists of open source software.

https://github.com/ahmadalsajid/oha-docker

Lightweight, multi-arch, minimal docker image of OHA, inspired by rakyll/hey,
https://github.com/ahmadalsajid/oha-docker

Last synced: 3 months ago
JSON representation

Lightweight, multi-arch, minimal docker image of OHA, inspired by rakyll/hey,

Awesome Lists containing this project

README

        

# oha-docker

[![Github Actions](https://github.com/ahmadalsajid/oha-docker/actions/workflows/actions.yml/badge.svg?branch=main)](https://github.com/ahmadalsajid/oha-docker/actions/workflows/actions.yml/badge.svg?branch=main)

Minimal, Multi-arch, lightweight docker image of [OHA](https://github.com/hatoo/oha),
inspired by [rakyll/hey](https://github.com/rakyll/hey),

Oha is written in Rust and powered by [tokio](https://github.com/tokio-rs/tokio)
and beautiful tui by [ratatui](https://github.com/ratatui-org/ratatui).

![Demo](./demo.gif)

## Installation

```
$ docker pull ahmadalsajid/oha-docker
```

## Usage

`ahmadalsajid/oha-docker` runs provided number of requests in the provided
concurrency level and prints stats. A basic usage could be

```
$ docker run --rm -it ahmadalsajid/oha-docker -n 1000 -c 100 https://google.com
```

Also, local http services can be tested with `ahmadalsajid/oha-docker`. Take
this structure as an example

```
services:
nginx:
build: ./nginx
hostname: nginx
ports:
- 1337:80
depends_on:
- app
networks:
- my_network

app:
build: ./app
hostname: app
ports:
- 8000
networks:
- my_network

networks:
my_network:
name: my_network
driver: bridge
```

The tests can be conducted with

```
$ docker run --network host --rm -it ahmadalsajid/oha-docker -n 1000 -c 100 http://localhost:1337/
```

Or,

```
$ docker run --network my_network --rm -it ahmadalsajid/oha-docker -n 1000 -c 100 http://nginx/
```

> In the first example,oha-docker connected to the host network, that's
> why targeting `localhost` on port `1337`.
> In the second example, connected to the custom network that other services
> are running, hence, pointed using the service name.

`-q` option works different from [rakyll/hey](https://github.com/rakyll/hey).
It's set overall query per second instead of for each worker.

```bash
Options:
-n Number of requests to run. [default: 200]
-c Number of connections to run concurrently. You may should increase limit to number of open files for larger `-c`. [default: 50]
-p Number of parallel requests to send on HTTP/2. `oha` will run c * p concurrent workers in total. [default: 1]
-z Duration of application to send requests. If duration is specified, n is ignored.
When the duration is reached, ongoing requests are aborted and counted as "aborted due to deadline"
Examples: -z 10s -z 3m.
-q Rate limit for all, in queries per second (QPS)
--burst-delay Introduce delay between a predefined number of requests.
Note: If qps is specified, burst will be ignored
--burst-rate 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 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 Frame per second for tui. [default: 16]
-m, --method HTTP method [default: GET]
-H Custom HTTP header. Examples: -H "foo: bar"
-t Timeout for each request. Default to infinite.
-A HTTP Accept Header.
-d HTTP request body.
-D HTTP request body from file.
-T Content-Type.
-a Basic authentication, username:password
--http-version HTTP version. Available values 0.9, 1.0, 1.1.
--http2 Use HTTP/2. Shorthand for --http-version=2
--host HTTP Host header
--disable-compression Disable compression.
-r, --redirect Limit for number of Redirect. Set 0 for no redirection. Redirection isn't supported for HTTP/2. [default: 10]
--disable-keepalive Disable keep-alive, prevents re-use of TCP connections between different HTTP requests. This isn't supported for HTTP/2.
--no-pre-lookup *Not* perform a DNS lookup at beginning to cache it
--ipv6 Lookup only ipv6.
--ipv4 Lookup only ipv4.
--insecure Accept invalid certs.
--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 Connect to a unix socket instead of the domain in the URL. Only for non-HTTPS URLs.
--vsock-addr Connect to a VSOCK socket using 'cid:port' instead of the domain in the URL. Only for non-HTTPS URLs.
--stats-success-breakdown Include a response status code successful or not successful breakdown for the time histogram and distribution statistics
-h, --help Print help
-V, --version Print version
```

## JSON output

`oha` prints JSON output when `-j` option is set.
The schema of JSON output is defined in [schema.json](https://github.com/hatoo/oha/blob/master/schema.json).