Skip to content

Commit

Permalink
Integrating hloader
Browse files Browse the repository at this point in the history
Signed-off-by: Raul Sevilla <[email protected]>
  • Loading branch information
rsevilla87 committed Oct 25, 2023
1 parent 944be66 commit 0c78c6e
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 36 deletions.
36 changes: 20 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,29 @@ OCP Ingress performance ultimate tool!

Ingress-perf configuration is defined in a YAML file, holding an array of the following structure. [Examples directory](./config)

| Field Name | Type | Description | Default Value |
|------------------|------------------|----------------------------------------------------------------------------------------------------------|---------------|
| `termination` | `string` | Defines the type of benchmark termination. Allowed values are `http`, `edge`, `reencrypt` and `reencrypt`. | N/A |
| `connections` | `int` | Defines the number of connections per client. | `0` |
| `samples` | `int` | Defines the number of samples per scenario. | `0` |
| `duration` | `time.Duration` | Defines the duration of each sample. | `""` |
| `path` | `string` | Defines the scenario endpoint path, for example: `/1024.html`, `/2048.html`. | `""` |
| `concurrency` | `int32` | Defines the number of clients that will concurrently run the benchmark scenario. | `0` |
| `tool` | `string` | Defines the tool to run the benchmark scenario. | `""` |
| `serverReplicas` | `int32` | Defines the number of server (nginx) replicas backed by the routes. | `0` |
| `tuningPatch` | `string` | Defines a JSON merge tuning patch for the default `IngressController` object. | `""` |
| `delay` | `time.Duration` | Defines a delay between samples. | `0s` |
| `warmup` | `bool` | Enables warmup: indexing will be disabled in this scenario. | `false` |
| `requestTimeout` | `time.Duration` | Request timeout | `1s` |
| `procs ` | `int` | Number of processes to trigger in each of the client pods | `1` |
| Field Name | Type | Description | Default Value | Tools |
|------------------|------------------|---------------------------------------------------------------------------------------------|---------------|------------------|
| `termination` | `string` | Benchmark termination. Allowed values are `http`, `edge`, `reencrypt` and `reencrypt`. | N/A | `wrk`,`hloader` |
| `connections` | `int` | Number of connections per client. | `0` | `wrk`,`hloader` |
| `samples` | `int` | Number of samples per scenario. | `0` | `wrk`,`hloader` |
| `duration` | `time.Duration` | Duration of each sample. | `""` | `wrk`,`hloader` |
| `path` | `string` | Scenario endpoint path, for example: `/1024.html`, `/2048.html`. | `""` | `wrk`,`hloader` |
| `concurrency` | `int32` | Number of clients that will concurrently run the benchmark scenario. | `0` | `wrk`,`hloader` |
| `tool` | `string` | Tool to run the benchmark scenario. | `""` | `wrk`,`hloader` |
| `serverReplicas` | `int32` | Number of server (nginx) replicas backed by the routes. | `0` | `wrk`,`hloader` |
| `tuningPatch` | `string` | Defines a JSON merge tuning patch for the default `IngressController` object. | `""` | `wrk`,`hloader` |
| `delay` | `time.Duration` | Delay between samples. | `0s` | `wrk`,`hloader` |
| `warmup` | `bool` | Enables warmup: indexing will be disabled in this scenario. | `false` | `wrk`,`hloader` |
| `requestTimeout` | `time.Duration` | Request timeout | `1s` | `wrk`,`hloader` |
| `procs` | `int` | Number of processes to trigger in each of the client pods | `1` | `wrk`,`hloader` |
| `keepalive` | `bool` | Use HTTP keepalived connections | `true` | `hloader` |
| `requestRate` | `int` | Number of requests per second | `0` (unlimited) | `hloader` |
| `http2` | `bool` | Use HTTP2 requests, when possible | `false` | `hloader` |

## Supported tools

- wrk: HTTP benchmarking tool. https://github.com/wg/wrk
- wrk: HTTP benchmarking tool. https://github.com/wg/wrk. amd64 and arm64
- hloader: https://github.com/rsevilla87/hloader

## Running

Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func (c *Config) UnmarshalYAML(unmarshal func(interface{}) error) error {
Warmup: false, // Disable warmup by default
RequestTimeout: time.Second,
Procs: 1,
Keepalive: true,
}
if err := unmarshal(&defaultCfg); err != nil {
return err
Expand Down
10 changes: 8 additions & 2 deletions pkg/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,15 @@ type Config struct {
// Tuning defines a tuning patch for the default IngressController object
Tuning string `yaml:"tuningPatch" json:"tuningPatch"`
// Delay defines a delay between samples
Delay time.Duration `yaml:"delay"`
Delay time.Duration `yaml:"delay" json:"delay"`
// Warmup enables warmup: Indexing will be disabled in this scenario. Default is false
Warmup bool `yaml:"warmup" json:"-"`
// RequestTimeout defines the tool request timeout
RequestTimeout time.Duration `yaml:"requestTimeout"`
RequestTimeout time.Duration `yaml:"requestTimeout" json:"requestTimeout"`
// RequestRate defines the amount of requests to run in parallel
RequestRate int `yaml:"requestRate" json:"requestRate"`
// Keepalive use keepalived connections
Keepalive bool `yaml:"keepalive" json:"keepalive"`
// Use HTTP2 protocol, if possible
HTTP2 bool `yaml:"http2" json:"http2"`
}
2 changes: 1 addition & 1 deletion pkg/runner/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func runBenchmark(cfg config.Config, clusterMetadata tools.ClusterMetadata) ([]t
}
}
if err = errGroup.Wait(); err != nil {
log.Error("Errors found during execution, skipping sample")
log.Errorf("Errors found during execution, skipping sample: %s", err)
continue
}
genResultSummary(&result)
Expand Down
54 changes: 54 additions & 0 deletions pkg/runner/tools/hloader.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright 2023 The ingress-perf Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package tools

import (
"encoding/json"
"fmt"

"github.com/cloud-bulldozer/ingress-perf/pkg/config"
)

type hLoader struct {
cmd []string
res PodResult
}

func init() {
toolMap["hloader"] = HLoader
}

func HLoader(cfg config.Config, ep string) Tool {
newHLoader := &hLoader{
cmd: []string{"hloader", "-u", ep,
"-c", fmt.Sprint(cfg.Connections),
"-d", fmt.Sprint(cfg.Duration),
"-r", fmt.Sprint(cfg.RequestRate),
"-t", fmt.Sprint(cfg.RequestTimeout),
"-k", fmt.Sprint(cfg.Keepalive),
"--http2", fmt.Sprint(cfg.HTTP2),
},
res: PodResult{},
}
return newHLoader
}

func (w *hLoader) Cmd() []string {
return w.cmd
}

func (w *hLoader) ParseResult(stdout, _ string) (PodResult, error) {
return w.res, json.Unmarshal([]byte(stdout), &w.res)
}
34 changes: 18 additions & 16 deletions pkg/runner/tools/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,24 @@ type Tool interface {
}

type PodResult struct {
Name string `json:"pod"`
Node string `json:"node"`
InstanceType string `json:"instanceType"`
AvgRps float64 `json:"rps"`
StdevRps float64 `json:"rps_stdev"`
StdevLatency float64 `json:"stdev_lat"`
AvgLatency float64 `json:"avg_lat_us"`
MaxLatency float64 `json:"max_lat_us"`
P90Latency int64 `json:"p90_lat_us"`
P95Latency int64 `json:"p95_lat_us"`
P99Latency int64 `json:"p99_lat_us"`
HTTPErrors int64 `json:"http_errors"`
ReadErrors int64 `json:"read_errors"`
WriteErrors int64 `json:"write_errors"`
Requests int64 `json:"requests"`
Timeouts int64 `json:"timeouts"`
Name string `json:"pod"`
Node string `json:"node"`
InstanceType string `json:"instanceType"`
AvgRps float64 `json:"rps"`
StdevRps float64 `json:"rps_stdev"`
StdevLatency float64 `json:"stdev_lat"`
AvgLatency float64 `json:"avg_lat_us"`
MaxLatency float64 `json:"max_lat_us"`
P90Latency float64 `json:"p90_lat_us"`
P95Latency float64 `json:"p95_lat_us"`
P99Latency float64 `json:"p99_lat_us"`
HTTPErrors int64 `json:"http_errors"`
ReadErrors int64 `json:"read_errors"`
WriteErrors int64 `json:"write_errors"`
Requests int64 `json:"requests"`
Timeouts int64 `json:"timeouts"`
AvgThgoughputBps int64 `json:"avg_throughput_bps"`
StatusCodes map[int]int64 `json:"status_codes"`
}

type Result struct {
Expand Down
2 changes: 1 addition & 1 deletion pkg/runner/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const (
benchmarkNs = "ingress-perf"
serverImage = "quay.io/cloud-bulldozer/nginx:latest"
serverName = "nginx"
clientImage = "quay.io/cloud-bulldozer/ingress-perf:latest"
clientImage = "quay.io/rsevilla/ingress-perf:latest"
clientName = "ingress-perf-client"
)

Expand Down

0 comments on commit 0c78c6e

Please sign in to comment.