Skip to content

Commit

Permalink
Merge pull request kubernetes#2299 from serathius/request-benchmark
Browse files Browse the repository at this point in the history
Improve request benchmark test
  • Loading branch information
k8s-ci-robot authored Jul 14, 2023
2 parents edb4057 + 821b7b7 commit f6620cb
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 8 deletions.
6 changes: 4 additions & 2 deletions clusterloader2/testing/request-benchmark/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{{$benchmarkReplicas := DefaultParam .CL2_BENCHMARK_PODS 1}}

{{$inflight := DefaultParam .CL2_BENCHMARK_INFLIGHT 10}}
{{$qps := DefaultParam .CL2_BENCHMARK_QPS -1}}
{{$uri := DefaultParam .CL2_BENCHMARK_URI ""}} # URI example: /api/v1/namespaces/%namespace%/pods

name: Request benchmark
Expand All @@ -13,7 +14,7 @@ namespace:
tuningSets:
- name: Sequence
parallelismLimitedLoad:
parallelismLimit: 1
parallelismLimit: 10
steps:
- name: Setup permissions
phases:
Expand Down Expand Up @@ -43,7 +44,7 @@ steps:
objectBundle:
- basename: {{$configMapGroup}}
objectTemplatePath: configmap.yaml
params:
templateFillMap:
bytes: {{$configMapBytes}}
group: {{$configMapGroup}}
- module:
Expand All @@ -56,6 +57,7 @@ steps:
replicas: {{$benchmarkReplicas}}
inflight: {{$inflight}}
uri: {{$uri}}
qps: {{$qps}}
- module:
path: modules/measurements.yaml
params:
Expand Down
4 changes: 2 additions & 2 deletions clusterloader2/testing/request-benchmark/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{$bytes := DefaultParam .bytes 0}}
{{$bytes := .bytes}}
{{$group := DefaultParam .group .Name}}

apiVersion: v1
Expand All @@ -8,4 +8,4 @@ metadata:
labels:
group: {{$group}}
data:
key: "{{range $i := Loop $bytes}}{{RandIntRange 0 9}}{{end}}"
key: "{{RandData $bytes}}"
1 change: 1 addition & 0 deletions clusterloader2/testing/request-benchmark/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ spec:
- --inflight={{.Inflight}}
- --namespace={{.Namespace}}
- --uri={{.Uri}}
- --qps={{.QPS}}
resources:
requests:
cpu: {{$cpu}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{$replicas := DefaultParam .replicas 0}}
{{$inflight := DefaultParam .inflight 0}}
{{$uri := DefaultParam .uri "/"}}
{{$qps := DefaultParam .qps -1}}

steps:
- name: Creating WaitForControlledPodsRunning measurement
Expand Down Expand Up @@ -28,6 +29,7 @@ steps:
Replicas: {{$replicas}}
Inflight: {{$inflight}}
Uri: {{$uri}}
QPS: {{$qps}}
- name: Waiting for WaitForControlledPodsRunning gather
measurements:
- Identifier: WaitForBenchmarkDeployment
Expand Down
12 changes: 12 additions & 0 deletions clusterloader2/testing/request-benchmark/modules/measurements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ steps:
duration: 1m
- name: "Starting measurement - {{.name}}"
measurements:
- Identifier: APIResponsivenessPrometheusSimple
Method: APIResponsivenessPrometheus
Params:
action: start
enableViolations: false
useSimpleLatencyQuery: true
- Identifier: ContainerCPU-{{.name}}
Method: GenericPrometheusQuery
Params:
Expand Down Expand Up @@ -49,3 +55,9 @@ steps:
query: quantile_over_time(0.90, sum by (container) (rate(container_cpu_usage_seconds_total[1m]))[%v:])
- name: Perc50
query: quantile_over_time(0.50, sum by (container) (rate(container_cpu_usage_seconds_total[1m]))[%v:])
- Identifier: APIResponsivenessPrometheusSimple
Method: APIResponsivenessPrometheus
Params:
action: gather
enableViolations: false
useSimpleLatencyQuery: true
2 changes: 1 addition & 1 deletion util-images/request-benchmark/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PROJECT ?= k8s-testimages
IMG = gcr.io/$(PROJECT)/perf-tests-util/request-benchmark
TAG = v0.0.5
TAG = v0.0.6

all: build push

Expand Down
5 changes: 3 additions & 2 deletions util-images/request-benchmark/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@ func (c *Client) TimedRequest(ctx context.Context, request *rest.Request) Respon
}
}

func GetClient() (*Client, error) {
func GetClient(qps float32) (*Client, error) {
config, err := getConfig()
if err != nil {
return nil, err
}

config.QPS = -1 // Disable rate limiter
config.QPS = qps
config.Burst = 10

client, err := kubernetes.NewForConfig(config)
return (*Client)(client), err
Expand Down
3 changes: 2 additions & 1 deletion util-images/request-benchmark/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ var (
namespace = flag.String("namespace", "", "Replace %namespace% in URI with provided namespace")
URI = flag.String("uri", "", "Request URI")
verb = flag.String("verb", "GET", "A verb to be used in requests.")
qps = flag.Float64("qps", -1, "The qps limit for all requests")
)

func init() {
flag.Parse()
}

func main() {
client, err := GetClient()
client, err := GetClient(float32(*qps))
if err != nil {
panic(err)
}
Expand Down

0 comments on commit f6620cb

Please sign in to comment.