Сохранять из логов прогона только изменения состояния балансировщика и реплик, сжимать посекундные метрики
This commit is contained in:
@@ -38,6 +38,15 @@ host_probe() {
|
|||||||
-c 'time -p awk "BEGIN{for(i=0;i<5000000;i++)s+=i}"' 2>&1 | awk '/^real/ { print $2 }'
|
-c 'time -p awk "BEGIN{for(i=0;i<5000000;i++)s+=i}"' 2>&1 | awk '/^real/ { print $2 }'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# state_log keeps from `compose logs` (stdin) what explains a run: the
|
||||||
|
# balancer's server state changes and the replicas' start and stop. An
|
||||||
|
# overloaded run logs every failed request, gigabytes over a series; those
|
||||||
|
# lines are only counted.
|
||||||
|
state_log() {
|
||||||
|
awk '/is DOWN|is UP|UP\/READY|maintenance|"msg":"(starting|shutdown started|shutdown completed)"/ { print; next }
|
||||||
|
{ dropped++ } END { printf "# %d other lines dropped\n", dropped }'
|
||||||
|
}
|
||||||
|
|
||||||
# sample_docker_stats appends the CPU and memory of every container until killed.
|
# sample_docker_stats appends the CPU and memory of every container until killed.
|
||||||
sample_docker_stats() {
|
sample_docker_stats() {
|
||||||
while :; do
|
while :; do
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ under 1 % errors, p99 of successful requests within 500 ms). Charts show the
|
|||||||
median of the repeats; a hollow marker means the generator fell behind.
|
median of the repeats; a hollow marker means the generator fell behind.
|
||||||
"""
|
"""
|
||||||
import csv
|
import csv
|
||||||
|
import gzip
|
||||||
import json
|
import json
|
||||||
import pathlib
|
import pathlib
|
||||||
import statistics
|
import statistics
|
||||||
@@ -40,10 +41,15 @@ COMPONENTS = ("api", "lb", "postgres", "valkey", "loadgen")
|
|||||||
|
|
||||||
|
|
||||||
def read_jsonl(path):
|
def read_jsonl(path):
|
||||||
if not path.exists():
|
packed = path.with_name(path.name + ".gz")
|
||||||
|
if packed.exists():
|
||||||
|
text = gzip.decompress(packed.read_bytes()).decode("utf-8")
|
||||||
|
elif path.exists():
|
||||||
|
text = path.read_text(encoding="utf-8")
|
||||||
|
else:
|
||||||
return []
|
return []
|
||||||
rows = []
|
rows = []
|
||||||
for line in path.read_text(encoding="utf-8").splitlines():
|
for line in text.splitlines():
|
||||||
line = line.strip()
|
line = line.strip()
|
||||||
if line:
|
if line:
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -58,7 +58,8 @@ run_config() {
|
|||||||
echo " loadgen failed, see $dir/loadgen.log"
|
echo " loadgen failed, see $dir/loadgen.log"
|
||||||
kill "$stats" "$pg" 2>/dev/null || true
|
kill "$stats" "$pg" 2>/dev/null || true
|
||||||
wait "$stats" "$pg" 2>/dev/null || true
|
wait "$stats" "$pg" 2>/dev/null || true
|
||||||
docker compose logs --no-color --timestamps lb api >"$dir/compose.log" 2>&1
|
docker compose logs --no-color --timestamps lb api 2>&1 | state_log >"$dir/compose.log"
|
||||||
|
gzip -9 "$dir"/*.jsonl
|
||||||
grep '^step' "$dir/loadgen.log" || true
|
grep '^step' "$dir/loadgen.log" || true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user