Skip to content

Commit

Permalink
Add new CLI argument (#13)
Browse files Browse the repository at this point in the history
* Add new CLI argument

Add support for `-ab-time-per-request` CLI argument, which will show
Apache Benchmark style `Time per request` metrics.

Closes: #12

* Fix Makrdown
  • Loading branch information
adidenko authored Feb 1, 2022
1 parent d74fc6b commit 8afc7d8
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 14 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.4.1] - 2022-02-01

### Added

- New CLI arg `--ab-time-per-request` show Apache Benchmark style time per request
metric, which is hidden by default. Fixes #12.

### Removed

- `OverallRequestTimeSeconds` has been removed from the JSON report to avoid confusion.
Related to #12.

## [0.4.0] - 2021-12-07

### Added
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ Completed requests: 1517
Succeeded requests: 1517
Failed requests: 0
Requests per second: 50.57 (mean, across all concurrent requests)
Request duration 19.78ms (mean, across all concurrent requests)
Transfer rate (HTTP Message Body) 319 kB/s sent (mean)
253 kB/s sent (mean, across all concurrent requests)
637 kB/s received (mean)
Expand Down Expand Up @@ -104,7 +103,6 @@ Completed requests: 222
Succeeded requests: 222
Failed requests: 0
Requests per second: 20.25 (mean, across all concurrent requests)
Request duration 49.37ms (mean, across all concurrent requests)
Transfer rate (HTTP Message Body) 279 kB/s sent (mean)
101 kB/s sent (mean, across all concurrent requests)
558 kB/s received (mean)
Expand Down Expand Up @@ -234,6 +232,16 @@ you need to do this:

See the [open issues](https://github.com/wayfair-incubator/minigun/issues) for a list of proposed features (and known issues).

## Release Management

- Push changes via Github Pull Requests, review and merge them.
- Change the version constant in the `main.go` file.
- Add all changes introduced since the last release to the `CHANGELOG.md` file.
- When the new release is ready, [draft a new release](https://github.com/wayfair-incubator/minigun/releases/new):
- Make sure to specify a new tag, make sure to follow [SemVer spec](https://semver.org/spec/v2.0.0.html).
- Publish the new release.
- All artifacts should be published automatically shortly after the new release is published.

## Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**. For detailed contributing guidelines, please see [CONTRIBUTING.md](CONTRIBUTING.md)
Expand Down
10 changes: 6 additions & 4 deletions docs/report-help.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ minigun -fire-target http://kube-echo-perf-test.test.cluster.local/echo/1 \
-random-body-size 1KB \
-fire-rate 10 \
-workers 5 \
-fire-duration 1m
-fire-duration 1m \
-ab-time-per-request
```

Result:
Expand All @@ -29,7 +30,8 @@ Completed requests: 599
Succeeded requests: 599
Failed requests: 0
Requests per second: 9.98 (mean, across all concurrent requests)
Request duration 100.17ms (mean, across all concurrent requests)
Time per request 1.81ms (mean)
Time per request 100.17ms (mean, across all concurrent requests)
Transfer rate (HTTP Message Body) 552 kB/s sent (mean)
10 kB/s sent (mean, across all concurrent requests)
552 kB/s received (mean)
Expand All @@ -56,9 +58,9 @@ of per worker metrics**.

So in the example above we're running 5 workers with desired request rate 10 reqs/s:

- `Full request duration 1.81ms (MEAN)` - every worker calculates exact time it takes
- `Time per request 1.81ms (mean)` - every worker calculates exact time it takes
to process the HTTP request. And this is the average of all the workers' metrics.
- `Request duration 100.17ms (mean, across all concurrent requests)` - we're running
- `Time per request 100.17ms (mean, across all concurrent requests)` - we're running
10 requests per second from 5 workers, and since every worker can complete this request
in `~1.81ms`, then we're not constrained by the app performance and can do 10 reqs/s
exactly. Simple math shows that expected request time is `1 second / 10 requests`
Expand Down
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
)

// Constants and vars
const version = "0.4.0"
const version = "0.4.1"
const workersCannelSize = 1024
const errorBadHTTPCode = "Bad HTTP status code"

Expand All @@ -59,6 +59,8 @@ type appConfig struct {
instance string
name string

abTimePerRequest bool

pushGateway string
pushInterval time.Duration

Expand Down Expand Up @@ -635,6 +637,8 @@ func main() {
flag.StringVar(&config.report, "report", "text", "Report format. One of: 'text', 'table', 'json'")
flag.BoolVar(&config.prettyJson, "pretty-json", false, "Pretty print JSON report with indents")

flag.BoolVar(&config.abTimePerRequest, "ab-time-per-request", false, "Show Apache Benchmark style time per request metric")

flag.StringVar(&config.name, "name", "default", "Benchmark run name. It will be used as 'name' label for metrics. Can be used for grouping all instances.")
flag.StringVar(&config.instance, "instance", "", "Benchmark instance name. It will be used as 'instance' label for metrics. Default to hostname.")
flag.StringVar(&config.pushGateway, "push-gateway", "", "Prometheus Pushgateway URL")
Expand Down
16 changes: 9 additions & 7 deletions report.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ type appReport struct {
RequestsFailed float64 `json:"RequestsFailed"`

OverallRequestsRate float64 `json:"OverallRequestsRate"`
OverallRequestTimeSeconds float64 `json:"OverallRequestTimeSeconds"`
OverallSentBytesPerSecond float64 `json:"OverallSentBytesPerSecond"`
OverallReceivedBytesPerSecond float64 `json:"OverallReceivedBytesPerSecond"`

Expand Down Expand Up @@ -99,9 +98,6 @@ func collectReport(config appConfig, duration float64) appReport {

if requests, err := getCounter(config.metrics.requestsSendCount, config.metrics.labelValues...); err == nil {
report.OverallRequestsRate = requests / duration

// Request time over all, cross all the concurency workers
report.OverallRequestTimeSeconds = duration / float64(requests)
}

// Time per request and transfer rates
Expand Down Expand Up @@ -272,9 +268,15 @@ func reportTextOld(config appConfig, duration float64) string {
rate := requests / duration
outMatrix = append(outMatrix, printRow{"Requests per second:", fmt.Sprintf("%.2f (mean, across all concurrent requests)", rate)})

// Request time over all, cross all the concurency workers
overallRequestTime := humanizeDurationSeconds(duration / float64(requests))
outMatrix = append(outMatrix, printRow{"Request duration", fmt.Sprintf("%v (mean, across all concurrent requests)", overallRequestTime)})
if config.abTimePerRequest {
// Mean request time
if _, _, mean, _, err := getSummaryValues(registry, "minigun_requests_duration_seconds", config.metrics.labels); err == nil {
outMatrix = append(outMatrix, printRow{"Time per request", fmt.Sprintf("%v (mean)", humanizeDurationSeconds(mean))})
}
// Request time over all, cross all the concurency workers
overallRequestTime := humanizeDurationSeconds(duration / float64(requests))
outMatrix = append(outMatrix, printRow{"Time per request", fmt.Sprintf("%v (mean, across all concurrent requests)", overallRequestTime)})
}
}

// Time per request and transfer rates
Expand Down

0 comments on commit 8afc7d8

Please sign in to comment.