mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-25 10:18:59 +02:00
refactor(benchmark): benchmark script functionality and fairness
This commit is contained in:
6
Makefile
6
Makefile
@@ -124,7 +124,11 @@ dev-build: build
|
|||||||
docker compose -f dev.compose.yml up -t 0 -d app --force-recreate
|
docker compose -f dev.compose.yml up -t 0 -d app --force-recreate
|
||||||
|
|
||||||
benchmark:
|
benchmark:
|
||||||
@docker compose -f dev.compose.yml up -d --force-recreate whoami godoxy traefik caddy nginx
|
@if [ -z "$(TARGET)" ]; then \
|
||||||
|
docker compose -f dev.compose.yml up -d --force-recreate whoami godoxy traefik caddy nginx; \
|
||||||
|
else \
|
||||||
|
docker compose -f dev.compose.yml up -d --force-recreate whoami $(TARGET); \
|
||||||
|
fi
|
||||||
sleep 1
|
sleep 1
|
||||||
@./scripts/benchmark.sh
|
@./scripts/benchmark.sh
|
||||||
|
|
||||||
|
|||||||
@@ -184,11 +184,11 @@ configs:
|
|||||||
default_bind 0.0.0.0
|
default_bind 0.0.0.0
|
||||||
|
|
||||||
servers {
|
servers {
|
||||||
protocols h2c h1
|
protocols h1 h2c
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
http://whoami.domain.com:80 {
|
http://whoami.domain.com {
|
||||||
reverse_proxy whoami:80
|
reverse_proxy whoami:80
|
||||||
}
|
}
|
||||||
nginx_config:
|
nginx_config:
|
||||||
@@ -221,6 +221,14 @@ configs:
|
|||||||
keepalive 128;
|
keepalive 128;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80 default_server;
|
||||||
|
server_name _;
|
||||||
|
http2 on;
|
||||||
|
|
||||||
|
return 404;
|
||||||
|
}
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen 80;
|
listen 80;
|
||||||
server_name whoami.domain.com;
|
server_name whoami.domain.com;
|
||||||
|
|||||||
@@ -6,9 +6,10 @@ set -e
|
|||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
HOST="whoami.domain.com"
|
HOST="whoami.domain.com"
|
||||||
DURATION="10s"
|
DURATION="${DURATION:-10s}"
|
||||||
THREADS=4
|
THREADS="${THREADS:-4}"
|
||||||
CONNECTIONS=100
|
CONNECTIONS="${CONNECTIONS:-100}"
|
||||||
|
TARGET="${TARGET:-}"
|
||||||
|
|
||||||
# Color functions for output
|
# Color functions for output
|
||||||
red() { echo -e "\033[0;31m$*\033[0m"; }
|
red() { echo -e "\033[0;31m$*\033[0m"; }
|
||||||
@@ -46,6 +47,9 @@ echo "Target: $HOST"
|
|||||||
echo "Duration: $DURATION"
|
echo "Duration: $DURATION"
|
||||||
echo "Threads: $THREADS"
|
echo "Threads: $THREADS"
|
||||||
echo "Connections: $CONNECTIONS"
|
echo "Connections: $CONNECTIONS"
|
||||||
|
if [ -n "$TARGET" ]; then
|
||||||
|
echo "Filter: $TARGET"
|
||||||
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Define services to test
|
# Define services to test
|
||||||
@@ -103,7 +107,9 @@ echo ""
|
|||||||
|
|
||||||
# Run connection tests for all services
|
# Run connection tests for all services
|
||||||
for name in "${!services[@]}"; do
|
for name in "${!services[@]}"; do
|
||||||
test_connection "$name" "${services[$name]}"
|
if [ -z "$TARGET" ] || [ "${name,,}" = "${TARGET,,}" ]; then
|
||||||
|
test_connection "$name" "${services[$name]}"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
@@ -152,7 +158,7 @@ run_benchmark() {
|
|||||||
h2load -t"$THREADS" -c"$CONNECTIONS" --duration="$h2_duration" \
|
h2load -t"$THREADS" -c"$CONNECTIONS" --duration="$h2_duration" \
|
||||||
-H "Host: $HOST" \
|
-H "Host: $HOST" \
|
||||||
-H ":authority: $HOST" \
|
-H ":authority: $HOST" \
|
||||||
"$url" | grep -vE "^(starting benchmark...|spawning thread #|progress: |Warm-up )"
|
"$url" | grep -vE "^(starting benchmark...|spawning thread|progress: |Warm-up |Main benchmark duration|Stopped all clients|Process Request Failure)"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
green "✓ $name benchmark completed"
|
green "✓ $name benchmark completed"
|
||||||
@@ -162,7 +168,9 @@ run_benchmark() {
|
|||||||
|
|
||||||
# Run benchmarks for each service
|
# Run benchmarks for each service
|
||||||
for name in "${!services[@]}"; do
|
for name in "${!services[@]}"; do
|
||||||
run_benchmark "$name" "${services[$name]}"
|
if [ -z "$TARGET" ] || [ "${name,,}" = "${TARGET,,}" ]; then
|
||||||
|
run_benchmark "$name" "${services[$name]}"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
blue "========================================"
|
blue "========================================"
|
||||||
|
|||||||
Reference in New Issue
Block a user