Skip to content

Commit 192953f

Browse files
committed
Add MAX_CONNECTIONS
1 parent 53bc5cf commit 192953f

File tree

2 files changed

+33
-17
lines changed

2 files changed

+33
-17
lines changed

.github/workflows/benchmark.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,14 @@ on:
2424
required: false
2525
default: '60s'
2626
type: string
27-
vus:
28-
description: 'Virtual users for k6'
27+
connections:
28+
description: 'Concurrent connections/virtual users'
29+
required: false
30+
default: 10
31+
type: number
32+
max_connections:
33+
description: 'Maximum connections/virtual users'
2934
required: false
30-
default: 100
3135
type: number
3236
tools:
3337
description: 'Comma-separated list of tools to run'
@@ -52,7 +56,8 @@ env:
5256
RATE: ${{ github.event.inputs.rate || 'max' }}
5357
DURATION_SEC: ${{ github.event.inputs.duration_sec || '30' }}
5458
REQUEST_TIMEOUT: ${{ github.event.inputs.request_timeout || '60s' }}
55-
VUS: ${{ github.event.inputs.vus || '100' }}
59+
CONNECTIONS: ${{ github.event.inputs.connections || '10' }}
60+
MAX_CONNECTIONS: ${{ github.event.inputs.max_connections || github.event.inputs.connections || '10' }}
5661
TOOLS: ${{ github.event.inputs.tools || 'fortio,vegeta,k6' }}
5762
WEB_CONCURRENCY: ${{ github.event.inputs.web_concurrency || '2' }}
5863

@@ -261,7 +266,8 @@ jobs:
261266
echo " - RATE: ${RATE}"
262267
echo " - DURATION_SEC: ${DURATION_SEC}"
263268
echo " - REQUEST_TIMEOUT: ${REQUEST_TIMEOUT}"
264-
echo " - VUS: ${VUS}"
269+
echo " - CONNECTIONS: ${CONNECTIONS}"
270+
echo " - MAX_CONNECTIONS: ${MAX_CONNECTIONS}"
265271
echo " - TOOLS: ${TOOLS}"
266272
echo " - WEB_CONCURRENCY: ${WEB_CONCURRENCY}"
267273
echo ""

spec/performance/bench.sh

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ set -euo pipefail
66
TARGET="http://${BASE_URL:-localhost:3001}/${ROUTE:-server_side_hello_world_hooks}"
77
# requests per second; if "max" will get maximum number of queries instead of a fixed rate
88
RATE=${RATE:-50}
9-
# virtual users for k6
10-
VUS=${VUS:-100}
9+
# concurrent connections/virtual users
10+
CONNECTIONS=${CONNECTIONS:-10}
11+
# maximum connections/virtual users
12+
MAX_CONNECTIONS=${MAX_CONNECTIONS:-$CONNECTIONS}
1113
DURATION_SEC=${DURATION_SEC:-10}
1214
DURATION="${DURATION_SEC}s"
1315
# request timeout (duration string like "60s", "1m", "90s")
@@ -20,8 +22,12 @@ if ! { [ "$RATE" = "max" ] || { [[ "$RATE" =~ ^[0-9]+(\.[0-9]+)?$ ]] && (( $(bc
2022
echo "Error: RATE must be 'max' or a positive number (got: '$RATE')" >&2
2123
exit 1
2224
fi
23-
if ! { [[ "$VUS" =~ ^[0-9]+$ ]] && [ "$VUS" -gt 0 ]; }; then
24-
echo "Error: VUS must be a positive integer (got: '$VUS')" >&2
25+
if ! { [[ "$CONNECTIONS" =~ ^[0-9]+$ ]] && [ "$CONNECTIONS" -gt 0 ]; }; then
26+
echo "Error: CONNECTIONS must be a positive integer (got: '$CONNECTIONS')" >&2
27+
exit 1
28+
fi
29+
if ! { [[ "$MAX_CONNECTIONS" =~ ^[0-9]+$ ]] && [ "$MAX_CONNECTIONS" -gt 0 ]; }; then
30+
echo "Error: MAX_CONNECTIONS must be a positive integer (got: '$MAX_CONNECTIONS')" >&2
2531
exit 1
2632
fi
2733
if ! { [[ "$DURATION_SEC" =~ ^[0-9]+(\.[0-9]+)?$ ]] && (( $(bc -l <<< "$DURATION_SEC > 0") )); }; then
@@ -70,27 +76,31 @@ echo "Warm-up complete"
7076
mkdir -p "$OUTDIR"
7177

7278
if [ "$RATE" = "max" ]; then
73-
FORTIO_ARGS=(-qps 0)
74-
VEGETA_ARGS=(-rate=infinity)
79+
if [ "$CONNECTIONS" != "$MAX_CONNECTIONS" ]; then
80+
echo "For RATE=max, CONNECTIONS (got $CONNECTIONS) and MAX_CONNECTIONS (got $MAX_CONNECTIONS) should be the same"
81+
exit 1
82+
fi
83+
FORTIO_ARGS=(-qps 0 -c "$CONNECTIONS")
84+
VEGETA_ARGS=(-rate=infinity --workers="$CONNECTIONS" --max-workers="$CONNECTIONS")
7585
K6_SCENARIOS="{
7686
max_rate: {
7787
executor: 'shared-iterations',
78-
vus: $VUS,
79-
iterations: $((VUS * DURATION_SEC * 10)),
88+
vus: $CONNECTIONS,
89+
iterations: $((CONNECTIONS * DURATION_SEC * 10)),
8090
maxDuration: '$DURATION'
8191
}
8292
}"
8393
else
84-
FORTIO_ARGS=(-qps "$RATE" -uniform)
85-
VEGETA_ARGS=(-rate="$RATE")
94+
FORTIO_ARGS=(-qps "$RATE" -uniform -c "$CONNECTIONS")
95+
VEGETA_ARGS=(-rate="$RATE" --workers="$CONNECTIONS" --max-workers="$MAX_CONNECTIONS")
8696
K6_SCENARIOS="{
8797
constant_rate: {
8898
executor: 'constant-arrival-rate',
8999
rate: $RATE,
90100
timeUnit: '1s',
91101
duration: '$DURATION',
92-
preAllocatedVUs: $VUS,
93-
maxVUs: $((VUS * 10))
102+
preAllocatedVUs: $CONNECTIONS,
103+
maxVUs: $MAX_CONNECTIONS
94104
}
95105
}"
96106
fi

0 commit comments

Comments
 (0)