Skip to content

Commit 41601ec

Browse files
Add simple stress test script (#12)
* Add simple stress test script * Update with review comments * Fix jar paths * Fix jar paths in readme * Review comments for linux support
1 parent 72a3690 commit 41601ec

File tree

4 files changed

+69
-2
lines changed

4 files changed

+69
-2
lines changed

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,54 @@ There are some [scripts](scripts) available to help you run the application:
4747
- Runs a set of requests against a running application.
4848
- [`infra.sh`](scripts/infra.sh)
4949
- Starts/stops required infrastructure
50+
51+
## Running performance comparisons
52+
53+
Of course you want to start generating some numbers and doing some comparisons, that's why you're here!
54+
There are lots of *wrong* ways to run benchmarks, and running them reliably requires a controlled environment, strong automation, and multiple machines.
55+
Realistically, that kind of setup isn't always possible.
56+
57+
Here's a range of options, from easiest to best practice.
58+
Remember that the easy setup will *not* be particularly accurate, but it does sidestep some of the worst pitfalls of casual benchmarking.
59+
60+
61+
### Quick and dirty: Single laptop, simple scripts
62+
63+
Before we go any further, know that this kind of test is not going to be reliable.
64+
Laptops usually have a number of other processes running on them, and modern laptop CPUs are subject to power management which can wildly skew results.
65+
Often, some cores are 'fast' and some are 'slow', and without extra care, you don't know which core your test is running on.
66+
Thermal management also means 'fast' jobs get throttled, while 'slow' jobs might run at their normal speed.
67+
68+
Load shouldn't be generated on the same machine as the one running the workload, because the work of load generation can interfere with what's being measured.
69+
70+
But if you accept all that, and know these results should be treated with caution, here's our recommendation for the least-worst way of running a quick and dirty test.
71+
We use [Hyperfoil](https://hyperfoil.io/https://hyperfoil.io/) instead of [wrk](https://github.com/wg/wrk), to avoid [coordinated omission](https://redhatperf.github.io/post/coordinated-omission/) issues. For simplicity, we use the [wrk2](https://github.com/giltene/wrk2) Hyperfoil bindings.
72+
73+
You can run these in any order.
74+
75+
```shell
76+
scripts/stress.sh quarkus3/target/quarkus-app/quarkus-run.jar
77+
scripts/stress.sh quarkus3-spring-compatibility/target/quarkus-app/quarkus-run.jar
78+
scripts/stress.sh springboot3/target/springboot3.jar
79+
```
80+
81+
For each test, you should see output like
82+
83+
```shell
84+
6001 requests in 30.002s, 4.84MB read
85+
Requests/sec: 200.02
86+
Transfer/sec: 165.29kB
87+
```
88+
### Acceptable: Run on a single machine, with solid automation and detailed output
89+
90+
These scripts are being developed.
91+
92+
### The best: Run tests in a controlled lab
93+
94+
These tests are run on a regular schedule in Red Hat/IBM performance labs.
95+
The results are available in an internal [Horreum](https://github.com/Hyperfoil/Horreum) instance.
96+
We are working on publishing these externally.
97+
98+
99+
100+

scripts/1strequest.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# Example usage
77
# 1) Run the Spring app 10 times
8-
# $ ./1strequest.sh "java -XX:ActiveProcessorCount=8 -Xms512m -Xmx512m -jar ../springboot3/target/app.jar" 10
8+
# $ ./1strequest.sh "java -XX:ActiveProcessorCount=8 -Xms512m -Xmx512m -jar ../springboot3/target/springboot3.jar" 10
99
#
1010
# 2) Run the Quarkus app 10 times
1111
# $ ./1strequest.sh "java -XX:ActiveProcessorCount=8 -Xms512m -Xmx512m -jar ../quarkus3/target/quarkus-app/quarkus-run.jar" 10

scripts/infra.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
22
set -euo pipefail
33

4+
thisdir="$(realpath $(dirname "$0"))"
5+
46
help() {
57
echo "This script starts the necessary services for the app in question"
68
echo
@@ -19,7 +21,7 @@ exit_abnormal() {
1921

2022
start_postgres() {
2123
echo "Starting PostgreSQL database '${DB_CONTAINER_NAME}'"
22-
local pid=$(${engine} run -d --rm=true --name ${DB_CONTAINER_NAME} -v ./dbdata:/docker-entrypoint-initdb.d/ -p 5432:5432 -e POSTGRES_USER=fruits -e POSTGRES_PASSWORD=fruits -e POSTGRES_DB=fruits postgres:17 > /dev/null)
24+
local pid=$(${engine} run -d --rm --name ${DB_CONTAINER_NAME} -v ${thisdir}/dbdata:/docker-entrypoint-initdb.d:O -p 5432:5432 -e POSTGRES_USER=fruits -e POSTGRES_PASSWORD=fruits -e POSTGRES_DB=fruits postgres:17)
2325
echo "PostgreSQL DB process: $pid"
2426

2527
echo "Waiting for PostgreSQL to be ready..."

scripts/stress.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
thisdir=`dirname "$0"`
4+
5+
# make sure the port is clear before enabling halting-on-error
6+
kill $(lsof -t -i:8080) &>/dev/null
7+
8+
set -euo pipefail
9+
10+
${thisdir}/infra.sh -s
11+
java -XX:ActiveProcessorCount=8 -Xms512m -Xmx512m -jar $1 &
12+
jbang wrk2@hyperfoil -t2 -c100 -d30s -R 200 --latency http://localhost:8080/fruits
13+
scripts/infra.sh -d
14+
kill $(lsof -t -i:8080) &>/dev/null

0 commit comments

Comments
 (0)